http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/Counter.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/Counter.java b/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/Counter.java index cb97600..c151e32 100644 --- a/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/Counter.java +++ b/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/Counter.java @@ -1,37 +1,37 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.deltaspike.config; - -import org.apache.deltaspike.core.api.config.ConfigProperty; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; - -@ApplicationScoped -public class Counter { - - @Inject - @ConfigProperty(name = "loop.size") - private Integer iterations; - - public int loop() { - for (int i = 0; i < iterations; i++) { - System.out.println("Iteration #" + i); - } - return iterations; - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.deltaspike.config; + +import org.apache.deltaspike.core.api.config.ConfigProperty; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; + +@ApplicationScoped +public class Counter { + + @Inject + @ConfigProperty(name = "loop.size") + private Integer iterations; + + public int loop() { + for (int i = 0; i < iterations; i++) { + System.out.println("Iteration #" + i); + } + return iterations; + } +}
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSource.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSource.java b/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSource.java index 5a5dd7c..9ff34b8 100644 --- a/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSource.java +++ b/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSource.java @@ -1,79 +1,79 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.deltaspike.config; - -import org.apache.deltaspike.core.impl.config.BaseConfigSource; -import org.apache.deltaspike.core.util.PropertyFileUtils; - -import java.io.IOException; -import java.net.URL; -import java.util.Collections; -import java.util.Enumeration; -import java.util.Map; -import java.util.Properties; -import java.util.logging.Logger; - -public class MyConfigSource extends BaseConfigSource { - - private static final Logger LOGGER = Logger.getLogger(MyConfigSource.class.getName()); - private static final String MY_CONF_FILE_NAME = "my-app-config.properties"; - - private final Properties properties; - - public MyConfigSource() { - final Enumeration<URL> in; - try { - in = Thread.currentThread().getContextClassLoader().getResources(MY_CONF_FILE_NAME); - } catch (IOException e) { - throw new IllegalArgumentException("can't find " + MY_CONF_FILE_NAME, e); - } - - properties = new Properties(); - - while (in.hasMoreElements()) { - final Properties currentProps = PropertyFileUtils.loadProperties(in.nextElement()); - for (Map.Entry<Object, Object> key : currentProps.entrySet()) { // some check - if (properties.containsKey(key.getKey().toString())) { - LOGGER.warning("found " + key.getKey() + " multiple times, only one value will be available."); - } - } - properties.putAll(currentProps); - } - - initOrdinal(401); // before other sources - } - - @Override - public Map<String, String> getProperties() { - return Collections.emptyMap(); // not scannable - } - - @Override - public String getPropertyValue(String key) { - return properties.getProperty(key); - } - - @Override - public String getConfigName() { - return MY_CONF_FILE_NAME; - } - - @Override - public boolean isScannable() { - return false; - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.deltaspike.config; + +import org.apache.deltaspike.core.impl.config.BaseConfigSource; +import org.apache.deltaspike.core.util.PropertyFileUtils; + +import java.io.IOException; +import java.net.URL; +import java.util.Collections; +import java.util.Enumeration; +import java.util.Map; +import java.util.Properties; +import java.util.logging.Logger; + +public class MyConfigSource extends BaseConfigSource { + + private static final Logger LOGGER = Logger.getLogger(MyConfigSource.class.getName()); + private static final String MY_CONF_FILE_NAME = "my-app-config.properties"; + + private final Properties properties; + + public MyConfigSource() { + final Enumeration<URL> in; + try { + in = Thread.currentThread().getContextClassLoader().getResources(MY_CONF_FILE_NAME); + } catch (IOException e) { + throw new IllegalArgumentException("can't find " + MY_CONF_FILE_NAME, e); + } + + properties = new Properties(); + + while (in.hasMoreElements()) { + final Properties currentProps = PropertyFileUtils.loadProperties(in.nextElement()); + for (Map.Entry<Object, Object> key : currentProps.entrySet()) { // some check + if (properties.containsKey(key.getKey().toString())) { + LOGGER.warning("found " + key.getKey() + " multiple times, only one value will be available."); + } + } + properties.putAll(currentProps); + } + + initOrdinal(401); // before other sources + } + + @Override + public Map<String, String> getProperties() { + return Collections.emptyMap(); // not scannable + } + + @Override + public String getPropertyValue(String key) { + return properties.getProperty(key); + } + + @Override + public String getConfigName() { + return MY_CONF_FILE_NAME; + } + + @Override + public boolean isScannable() { + return false; + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSourceProvider.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSourceProvider.java b/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSourceProvider.java index 4fd042c..e416a66 100644 --- a/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSourceProvider.java +++ b/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSourceProvider.java @@ -1,30 +1,30 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.deltaspike.config; - -import org.apache.deltaspike.core.spi.config.ConfigSource; -import org.apache.deltaspike.core.spi.config.ConfigSourceProvider; - -import java.util.Arrays; -import java.util.List; - -public class MyConfigSourceProvider implements ConfigSourceProvider { - @Override - public List<ConfigSource> getConfigSources() { - return Arrays.asList((ConfigSource) new MyConfigSource()); - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.deltaspike.config; + +import org.apache.deltaspike.core.spi.config.ConfigSource; +import org.apache.deltaspike.core.spi.config.ConfigSourceProvider; + +import java.util.Arrays; +import java.util.List; + +public class MyConfigSourceProvider implements ConfigSourceProvider { + @Override + public List<ConfigSource> getConfigSources() { + return Arrays.asList((ConfigSource) new MyConfigSource()); + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-configproperty/src/test/java/org/superbiz/deltaspike/config/ConfigTest.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-configproperty/src/test/java/org/superbiz/deltaspike/config/ConfigTest.java b/examples/deltaspike-configproperty/src/test/java/org/superbiz/deltaspike/config/ConfigTest.java index 49aff53..8f0a467 100644 --- a/examples/deltaspike-configproperty/src/test/java/org/superbiz/deltaspike/config/ConfigTest.java +++ b/examples/deltaspike-configproperty/src/test/java/org/superbiz/deltaspike/config/ConfigTest.java @@ -1,59 +1,59 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.deltaspike.config; - -import org.apache.deltaspike.core.impl.config.DefaultConfigSourceProvider; -import org.apache.deltaspike.core.spi.config.ConfigSourceProvider; -import org.apache.openjpa.lib.conf.MapConfigurationProvider; -import org.apache.ziplock.JarLocation; -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.ArchivePaths; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset; -import org.jboss.shrinkwrap.api.asset.EmptyAsset; -import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.Test; -import org.junit.runner.RunWith; - -import javax.inject.Inject; - -import static org.junit.Assert.assertNotNull; - -@RunWith(Arquillian.class) -public class ConfigTest { - - @Inject - private Counter counter; - - @Deployment - public static WebArchive jar() { - return ShrinkWrap.create(WebArchive.class) - .addClasses(Counter.class, MyConfigSource.class, MapConfigurationProvider.class) - .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml")) - .addAsResource(new ClassLoaderAsset("my-app-config.properties"), "my-app-config.properties") - .addAsLibraries(JarLocation.jarLocation(ConfigSourceProvider.class)) - .addAsLibraries(JarLocation.jarLocation(DefaultConfigSourceProvider.class)) - .addAsServiceProvider(ConfigSourceProvider.class, MyConfigSourceProvider.class); - } - - @Test - public void check() { - assertNotNull(counter); - counter.loop(); - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.deltaspike.config; + +import org.apache.deltaspike.core.impl.config.DefaultConfigSourceProvider; +import org.apache.deltaspike.core.spi.config.ConfigSourceProvider; +import org.apache.openjpa.lib.conf.MapConfigurationProvider; +import org.apache.ziplock.JarLocation; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.ArchivePaths; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import javax.inject.Inject; + +import static org.junit.Assert.assertNotNull; + +@RunWith(Arquillian.class) +public class ConfigTest { + + @Inject + private Counter counter; + + @Deployment + public static WebArchive jar() { + return ShrinkWrap.create(WebArchive.class) + .addClasses(Counter.class, MyConfigSource.class, MapConfigurationProvider.class) + .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml")) + .addAsResource(new ClassLoaderAsset("my-app-config.properties"), "my-app-config.properties") + .addAsLibraries(JarLocation.jarLocation(ConfigSourceProvider.class)) + .addAsLibraries(JarLocation.jarLocation(DefaultConfigSourceProvider.class)) + .addAsServiceProvider(ConfigSourceProvider.class, MyConfigSourceProvider.class); + } + + @Test + public void check() { + assertNotNull(counter); + counter.loop(); + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSExceptionHandler.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSExceptionHandler.java b/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSExceptionHandler.java index 81be407..3316b50 100644 --- a/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSExceptionHandler.java +++ b/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSExceptionHandler.java @@ -1,34 +1,34 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.deltaspike.exceptionhandling; - -import org.apache.deltaspike.core.api.exception.control.ExceptionHandler; -import org.apache.deltaspike.core.api.exception.control.Handles; -import org.apache.deltaspike.core.api.exception.control.event.ExceptionEvent; - -import java.util.logging.Logger; - -@ExceptionHandler -public class OSExceptionHandler { - - private static final Logger LOGGER = Logger.getLogger(OSExceptionHandler.class.getName()); - - public void printExceptions(@Handles final ExceptionEvent<OSRuntimeException> evt) { - LOGGER.severe("==> a bad OS was mentionned"); - evt.handled(); - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.deltaspike.exceptionhandling; + +import org.apache.deltaspike.core.api.exception.control.ExceptionHandler; +import org.apache.deltaspike.core.api.exception.control.Handles; +import org.apache.deltaspike.core.api.exception.control.event.ExceptionEvent; + +import java.util.logging.Logger; + +@ExceptionHandler +public class OSExceptionHandler { + + private static final Logger LOGGER = Logger.getLogger(OSExceptionHandler.class.getName()); + + public void printExceptions(@Handles final ExceptionEvent<OSRuntimeException> evt) { + LOGGER.severe("==> a bad OS was mentionned"); + evt.handled(); + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSRuntimeException.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSRuntimeException.java b/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSRuntimeException.java index 8973c06..35ca632 100644 --- a/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSRuntimeException.java +++ b/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSRuntimeException.java @@ -1,21 +1,21 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.deltaspike.exceptionhandling; - -public class OSRuntimeException extends RuntimeException { - -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.deltaspike.exceptionhandling; + +public class OSRuntimeException extends RuntimeException { + +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSValidator.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSValidator.java b/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSValidator.java index d123e96..1a1dadc 100644 --- a/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSValidator.java +++ b/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSValidator.java @@ -1,35 +1,35 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.deltaspike.exceptionhandling; - -import org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent; - -import javax.enterprise.event.Event; -import javax.inject.Inject; - -public class OSValidator { - - @Inject - private Event<ExceptionToCatchEvent> exceptionEvent; - - public void validOS(final String os) { - if (os.toLowerCase().contains("win")) { - final Exception ex = new OSRuntimeException(); // can be a caugh exceptino - exceptionEvent.fire(new ExceptionToCatchEvent(ex)); - } - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.deltaspike.exceptionhandling; + +import org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent; + +import javax.enterprise.event.Event; +import javax.inject.Inject; + +public class OSValidator { + + @Inject + private Event<ExceptionToCatchEvent> exceptionEvent; + + public void validOS(final String os) { + if (os.toLowerCase().contains("win")) { + final Exception ex = new OSRuntimeException(); // can be a caugh exceptino + exceptionEvent.fire(new ExceptionToCatchEvent(ex)); + } + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-exception-handling/src/test/java/org/superbiz/deltaspike/exceptionhandling/ExceptionHandlingDemoTest.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-exception-handling/src/test/java/org/superbiz/deltaspike/exceptionhandling/ExceptionHandlingDemoTest.java b/examples/deltaspike-exception-handling/src/test/java/org/superbiz/deltaspike/exceptionhandling/ExceptionHandlingDemoTest.java index f585324..27ca60b 100644 --- a/examples/deltaspike-exception-handling/src/test/java/org/superbiz/deltaspike/exceptionhandling/ExceptionHandlingDemoTest.java +++ b/examples/deltaspike-exception-handling/src/test/java/org/superbiz/deltaspike/exceptionhandling/ExceptionHandlingDemoTest.java @@ -1,58 +1,58 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.deltaspike.exceptionhandling; - -import org.apache.deltaspike.core.impl.config.DefaultConfigSourceProvider; -import org.apache.deltaspike.core.spi.config.ConfigSourceProvider; -import org.apache.ziplock.JarLocation; -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.ArchivePaths; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.EmptyAsset; -import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.Test; -import org.junit.runner.RunWith; - -import javax.inject.Inject; - -import static org.junit.Assert.assertNotNull; - -@RunWith(Arquillian.class) -public class ExceptionHandlingDemoTest { - - @Inject - private OSValidator validator; - - @Deployment - public static WebArchive jar() { - return ShrinkWrap.create(WebArchive.class) - .addPackage(OSValidator.class.getPackage()) - .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml")) - // DeltaSpike libs (api and impl) - .addAsLibraries(JarLocation.jarLocation(ConfigSourceProvider.class)) - .addAsLibraries(JarLocation.jarLocation(DefaultConfigSourceProvider.class)); - } - - @Test - public void check() { - assertNotNull(validator); - validator.validOS("Linux"); - validator.validOS("windows"); // should throw a handled exception - validator.validOS("Mac OS"); - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.deltaspike.exceptionhandling; + +import org.apache.deltaspike.core.impl.config.DefaultConfigSourceProvider; +import org.apache.deltaspike.core.spi.config.ConfigSourceProvider; +import org.apache.ziplock.JarLocation; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.ArchivePaths; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import javax.inject.Inject; + +import static org.junit.Assert.assertNotNull; + +@RunWith(Arquillian.class) +public class ExceptionHandlingDemoTest { + + @Inject + private OSValidator validator; + + @Deployment + public static WebArchive jar() { + return ShrinkWrap.create(WebArchive.class) + .addPackage(OSValidator.class.getPackage()) + .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml")) + // DeltaSpike libs (api and impl) + .addAsLibraries(JarLocation.jarLocation(ConfigSourceProvider.class)) + .addAsLibraries(JarLocation.jarLocation(DefaultConfigSourceProvider.class)); + } + + @Test + public void check() { + assertNotNull(validator); + validator.validOS("Linux"); + validator.validOS("windows"); // should throw a handled exception + validator.validOS("Mac OS"); + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/CustomProjectStage.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/CustomProjectStage.java b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/CustomProjectStage.java index 47a6b99..4bd451d 100644 --- a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/CustomProjectStage.java +++ b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/CustomProjectStage.java @@ -1,30 +1,30 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.superbiz.deltaspike; - -import org.apache.deltaspike.core.api.projectstage.ProjectStage; -import org.apache.deltaspike.core.api.projectstage.ProjectStageHolder; - -public class CustomProjectStage implements ProjectStageHolder { - public static final class Debugging extends ProjectStage { - private static final long serialVersionUID = -8626602281649294170L; - } - - public static final Debugging Debugging = new Debugging(); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.superbiz.deltaspike; + +import org.apache.deltaspike.core.api.projectstage.ProjectStage; +import org.apache.deltaspike.core.api.projectstage.ProjectStageHolder; + +public class CustomProjectStage implements ProjectStageHolder { + public static final class Debugging extends ProjectStage { + private static final long serialVersionUID = -8626602281649294170L; + } + + public static final Debugging Debugging = new Debugging(); +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/DebugPhaseListener.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/DebugPhaseListener.java b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/DebugPhaseListener.java index f17699e..da3db91 100644 --- a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/DebugPhaseListener.java +++ b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/DebugPhaseListener.java @@ -1,49 +1,49 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.superbiz.deltaspike; - -import org.apache.deltaspike.core.api.exclude.Exclude; -import org.apache.deltaspike.core.api.projectstage.ProjectStage; -import org.apache.deltaspike.jsf.api.listener.phase.JsfPhaseListener; - -import javax.faces.event.PhaseEvent; -import javax.faces.event.PhaseId; -import javax.faces.event.PhaseListener; -import java.util.logging.Logger; - -@Exclude(exceptIfProjectStage = {ProjectStage.Development.class, CustomProjectStage.Debugging.class}) - -@JsfPhaseListener -public class DebugPhaseListener implements PhaseListener { - private static final long serialVersionUID = 5899542118538949019L; - - private Logger logger = Logger.getLogger(Logger.class.getName()); - - public void beforePhase(PhaseEvent phaseEvent) { - this.logger.info("before " + phaseEvent.getPhaseId()); - } - - public void afterPhase(PhaseEvent phaseEvent) { - this.logger.info("after " + phaseEvent.getPhaseId()); - } - - public PhaseId getPhaseId() { - return PhaseId.ANY_PHASE; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.superbiz.deltaspike; + +import org.apache.deltaspike.core.api.exclude.Exclude; +import org.apache.deltaspike.core.api.projectstage.ProjectStage; +import org.apache.deltaspike.jsf.api.listener.phase.JsfPhaseListener; + +import javax.faces.event.PhaseEvent; +import javax.faces.event.PhaseId; +import javax.faces.event.PhaseListener; +import java.util.logging.Logger; + +@Exclude(exceptIfProjectStage = {ProjectStage.Development.class, CustomProjectStage.Debugging.class}) + +@JsfPhaseListener +public class DebugPhaseListener implements PhaseListener { + private static final long serialVersionUID = 5899542118538949019L; + + private Logger logger = Logger.getLogger(Logger.class.getName()); + + public void beforePhase(PhaseEvent phaseEvent) { + this.logger.info("before " + phaseEvent.getPhaseId()); + } + + public void afterPhase(PhaseEvent phaseEvent) { + this.logger.info("after " + phaseEvent.getPhaseId()); + } + + public PhaseId getPhaseId() { + return PhaseId.ANY_PHASE; + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/WebappMessageBundle.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/WebappMessageBundle.java b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/WebappMessageBundle.java index 6cff477..a3392fe 100644 --- a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/WebappMessageBundle.java +++ b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/WebappMessageBundle.java @@ -1,38 +1,38 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.superbiz.deltaspike; - -import org.apache.deltaspike.core.api.message.MessageBundle; -import org.apache.deltaspike.core.api.message.MessageContextConfig; - -@MessageBundle -@MessageContextConfig(messageSource = "org.superbiz.deltaspike.i18n.messages") -public interface WebappMessageBundle { - String msgAccessDenied(); - - String msgUserRegistered(String userName); - - String msgLoginSuccessful(); - - String msgLoginFailed(); - - String msgError(String message); - - String msgWelcome(); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.superbiz.deltaspike; + +import org.apache.deltaspike.core.api.message.MessageBundle; +import org.apache.deltaspike.core.api.message.MessageContextConfig; + +@MessageBundle +@MessageContextConfig(messageSource = "org.superbiz.deltaspike.i18n.messages") +public interface WebappMessageBundle { + String msgAccessDenied(); + + String msgUserRegistered(String userName); + + String msgLoginSuccessful(); + + String msgLoginFailed(); + + String msgError(String message); + + String msgWelcome(); +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/AbstractDomainObject.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/AbstractDomainObject.java b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/AbstractDomainObject.java index 7ab899f..5715a89 100644 --- a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/AbstractDomainObject.java +++ b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/AbstractDomainObject.java @@ -1,43 +1,43 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.superbiz.deltaspike.domain; - -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.MappedSuperclass; -import javax.persistence.Version; -import java.io.Serializable; - -@MappedSuperclass -public abstract class AbstractDomainObject implements Serializable { - @Id - @GeneratedValue - private Long id; - - @Version - private Long version; - - public boolean isTransient() { - return this.version == null; - } - - public Long getId() { - return id; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.superbiz.deltaspike.domain; + +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; +import javax.persistence.Version; +import java.io.Serializable; + +@MappedSuperclass +public abstract class AbstractDomainObject implements Serializable { + @Id + @GeneratedValue + private Long id; + + @Version + private Long version; + + public boolean isTransient() { + return this.version == null; + } + + public Long getId() { + return id; + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Comment.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Comment.java b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Comment.java index 798b374..26dbc76 100644 --- a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Comment.java +++ b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Comment.java @@ -1,53 +1,53 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.superbiz.deltaspike.domain; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.ManyToOne; - -@Entity -public class Comment extends AbstractDomainObject { - private static final long serialVersionUID = -5718296682587279635L; - - @Column(length = 2048) - private String description; - - @ManyToOne(optional = false) - private Feedback feedback; - - void setFeedback(Feedback feedback) { - this.feedback = feedback; - } - - /* - * generated - */ - - public Comment() { - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.superbiz.deltaspike.domain; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.ManyToOne; + +@Entity +public class Comment extends AbstractDomainObject { + private static final long serialVersionUID = -5718296682587279635L; + + @Column(length = 2048) + private String description; + + @ManyToOne(optional = false) + private Feedback feedback; + + void setFeedback(Feedback feedback) { + this.feedback = feedback; + } + + /* + * generated + */ + + public Comment() { + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Feedback.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Feedback.java b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Feedback.java index b837dfd..1247465 100644 --- a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Feedback.java +++ b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Feedback.java @@ -1,69 +1,69 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.superbiz.deltaspike.domain; - -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.OneToMany; -import java.util.ArrayList; -import java.util.List; - -@Entity -public class Feedback extends AbstractDomainObject { - private static final long serialVersionUID = -431924785266663236L; - - @Column(nullable = false, length = 32) - private String topic; - - @Column(length = 128) - private String description; - - @OneToMany(mappedBy = "feedback", cascade = CascadeType.ALL) - private List<Comment> comments = new ArrayList<Comment>(); - - public void addComment(Comment comment) { - comment.setFeedback(this); - this.comments.add(comment); - } - - /* - * generated - */ - - public List<Comment> getComments() { - return comments; - } - - public String getTopic() { - return topic; - } - - public String getDescription() { - return description; - } - - public void setTopic(String topic) { - this.topic = topic; - } - - public void setDescription(String description) { - this.description = description; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.superbiz.deltaspike.domain; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.OneToMany; +import java.util.ArrayList; +import java.util.List; + +@Entity +public class Feedback extends AbstractDomainObject { + private static final long serialVersionUID = -431924785266663236L; + + @Column(nullable = false, length = 32) + private String topic; + + @Column(length = 128) + private String description; + + @OneToMany(mappedBy = "feedback", cascade = CascadeType.ALL) + private List<Comment> comments = new ArrayList<Comment>(); + + public void addComment(Comment comment) { + comment.setFeedback(this); + this.comments.add(comment); + } + + /* + * generated + */ + + public List<Comment> getComments() { + return comments; + } + + public String getTopic() { + return topic; + } + + public String getDescription() { + return description; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public void setDescription(String description) { + this.description = description; + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/User.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/User.java b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/User.java index d050b53..e98a239 100644 --- a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/User.java +++ b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/User.java @@ -1,103 +1,103 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.superbiz.deltaspike.domain; - -import org.superbiz.deltaspike.domain.validation.DifferentName; -import org.superbiz.deltaspike.domain.validation.Name; -import org.superbiz.deltaspike.domain.validation.Partial; -import org.superbiz.deltaspike.domain.validation.UniqueUserName; -import org.superbiz.deltaspike.domain.validation.UserName; - -import javax.enterprise.inject.Typed; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.NamedQuery; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -@Table(name = "T_User") -@Entity -@NamedQuery(name = "findUserByName", query = "select u from User u where u.userName = :currentUser") -@DifferentName(groups = Partial.class) -@Typed() -public class User extends AbstractDomainObject { - private static final long serialVersionUID = 3810638653455000233L; - - @UserName(groups = UniqueUserName.class) - @Column(nullable = false, length = 9, unique = true) - private String userName; - - @Size(min = 2, max = 20, message = "invalid first name") - @NotNull - @Column - private String firstName; - - @Column - @Name(message = "invalid last name") - private String lastName; - - @Column - private String password; - - /* - * generated - */ - - public User() { - } - - public User(String userName, String firstName, String lastName) { - this.userName = userName; - this.firstName = firstName; - this.lastName = lastName; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.superbiz.deltaspike.domain; + +import org.superbiz.deltaspike.domain.validation.DifferentName; +import org.superbiz.deltaspike.domain.validation.Name; +import org.superbiz.deltaspike.domain.validation.Partial; +import org.superbiz.deltaspike.domain.validation.UniqueUserName; +import org.superbiz.deltaspike.domain.validation.UserName; + +import javax.enterprise.inject.Typed; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +@Table(name = "T_User") +@Entity +@NamedQuery(name = "findUserByName", query = "select u from User u where u.userName = :currentUser") +@DifferentName(groups = Partial.class) +@Typed() +public class User extends AbstractDomainObject { + private static final long serialVersionUID = 3810638653455000233L; + + @UserName(groups = UniqueUserName.class) + @Column(nullable = false, length = 9, unique = true) + private String userName; + + @Size(min = 2, max = 20, message = "invalid first name") + @NotNull + @Column + private String firstName; + + @Column + @Name(message = "invalid last name") + private String lastName; + + @Column + private String password; + + /* + * generated + */ + + public User() { + } + + public User(String userName, String firstName, String lastName) { + this.userName = userName; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentName.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentName.java b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentName.java index ff5d3d3..fa217e1 100644 --- a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentName.java +++ b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentName.java @@ -1,38 +1,38 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.superbiz.deltaspike.domain.validation; - -import javax.validation.Constraint; -import javax.validation.Payload; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -@Constraint(validatedBy = DifferentNameValidator.class) -@Target(TYPE) -@Retention(RUNTIME) -public @interface DifferentName { - String message() default "invalid name"; - - Class<?>[] groups() default {}; - - Class<? extends Payload>[] payload() default {}; -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.superbiz.deltaspike.domain.validation; + +import javax.validation.Constraint; +import javax.validation.Payload; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Constraint(validatedBy = DifferentNameValidator.class) +@Target(TYPE) +@Retention(RUNTIME) +public @interface DifferentName { + String message() default "invalid name"; + + Class<?>[] groups() default {}; + + Class<? extends Payload>[] payload() default {}; +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentNameValidator.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentNameValidator.java b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentNameValidator.java index 737186b..9337187 100644 --- a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentNameValidator.java +++ b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentNameValidator.java @@ -1,33 +1,33 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.superbiz.deltaspike.domain.validation; - -import org.superbiz.deltaspike.domain.User; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; - -public class DifferentNameValidator implements ConstraintValidator<DifferentName, User> { - public void initialize(DifferentName differentName) { - } - - public boolean isValid(User person, ConstraintValidatorContext constraintValidatorContext) { - return person == null || !(person.getFirstName() != null && person.getFirstName().equals(person.getLastName())); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.superbiz.deltaspike.domain.validation; + +import org.superbiz.deltaspike.domain.User; + +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; + +public class DifferentNameValidator implements ConstraintValidator<DifferentName, User> { + public void initialize(DifferentName differentName) { + } + + public boolean isValid(User person, ConstraintValidatorContext constraintValidatorContext) { + return person == null || !(person.getFirstName() != null && person.getFirstName().equals(person.getLastName())); + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Full.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Full.java b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Full.java index cfa4b11..72f569f 100644 --- a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Full.java +++ b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Full.java @@ -1,26 +1,26 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.superbiz.deltaspike.domain.validation; - -import javax.validation.GroupSequence; -import javax.validation.groups.Default; - -@GroupSequence({Default.class, UniqueUserName.class}) -public interface Full { -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.superbiz.deltaspike.domain.validation; + +import javax.validation.GroupSequence; +import javax.validation.groups.Default; + +@GroupSequence({Default.class, UniqueUserName.class}) +public interface Full { +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Name.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Name.java b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Name.java index fb96554..708095f 100644 --- a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Name.java +++ b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Name.java @@ -1,48 +1,48 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.superbiz.deltaspike.domain.validation; - -import javax.validation.Constraint; -import javax.validation.Payload; -import javax.validation.ReportAsSingleViolation; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -@Size(min = 2, max = 20) -@NotNull - -@Constraint(validatedBy = {}) -@ReportAsSingleViolation - -@Target({METHOD, FIELD, ANNOTATION_TYPE}) -@Retention(RUNTIME) -public @interface Name { - public abstract String message() default "invalid name"; - - public abstract Class<?>[] groups() default {}; - - public abstract Class<? extends Payload>[] payload() default {}; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.superbiz.deltaspike.domain.validation; + +import javax.validation.Constraint; +import javax.validation.Payload; +import javax.validation.ReportAsSingleViolation; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Size(min = 2, max = 20) +@NotNull + +@Constraint(validatedBy = {}) +@ReportAsSingleViolation + +@Target({METHOD, FIELD, ANNOTATION_TYPE}) +@Retention(RUNTIME) +public @interface Name { + public abstract String message() default "invalid name"; + + public abstract Class<?>[] groups() default {}; + + public abstract Class<? extends Payload>[] payload() default {}; } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Partial.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Partial.java b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Partial.java index 8edfa5a..d179918 100644 --- a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Partial.java +++ b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Partial.java @@ -1,22 +1,22 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.superbiz.deltaspike.domain.validation; - -public interface Partial { +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.superbiz.deltaspike.domain.validation; + +public interface Partial { } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UniqueUserName.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UniqueUserName.java b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UniqueUserName.java index 6e2b4b0..183874c 100644 --- a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UniqueUserName.java +++ b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UniqueUserName.java @@ -1,22 +1,22 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.superbiz.deltaspike.domain.validation; - -public interface UniqueUserName { +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.superbiz.deltaspike.domain.validation; + +public interface UniqueUserName { } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UserName.java ---------------------------------------------------------------------- diff --git a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UserName.java b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UserName.java index 80f4c85..e878625 100644 --- a/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UserName.java +++ b/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UserName.java @@ -1,44 +1,44 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.superbiz.deltaspike.domain.validation; - -import javax.validation.Constraint; -import javax.validation.Payload; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import javax.validation.groups.Default; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -@NotNull(groups = Default.class) -@Size(min = 2, max = 9, message = "invalid name", groups = Default.class) - -@Constraint(validatedBy = UniqueUserNameValidator.class) -@Target(FIELD) -@Retention(RUNTIME) -public @interface UserName { - String message() default "user-name exists already"; - - Class<?>[] groups() default {}; - - Class<? extends Payload>[] payload() default {}; -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.superbiz.deltaspike.domain.validation; + +import javax.validation.Constraint; +import javax.validation.Payload; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import javax.validation.groups.Default; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@NotNull(groups = Default.class) +@Size(min = 2, max = 9, message = "invalid name", groups = Default.class) + +@Constraint(validatedBy = UniqueUserNameValidator.class) +@Target(FIELD) +@Retention(RUNTIME) +public @interface UserName { + String message() default "user-name exists already"; + + Class<?>[] groups() default {}; + + Class<? extends Payload>[] payload() default {}; +}
