├── softwaremill-conf
├── src
│ ├── test
│ │ ├── resources
│ │ │ ├── test2.conf
│ │ │ └── test1.conf
│ │ └── java
│ │ │ └── com
│ │ │ └── softwaremill
│ │ │ └── common
│ │ │ └── conf
│ │ │ └── encoding
│ │ │ └── ConfigurationValueCoderTest.java
│ └── main
│ │ └── java
│ │ └── com
│ │ └── softwaremill
│ │ └── common
│ │ └── conf
│ │ ├── PropertiesProvider.java
│ │ ├── Config.java
│ │ ├── SystemPropertiesMapWrapper.java
│ │ ├── JBoss7DeployPropertiesProvider.java
│ │ ├── encoding
│ │ ├── ConfigurationValueCoder.java
│ │ ├── MasterPasswordStore.java
│ │ ├── server
│ │ │ └── MasterPasswordSetterClient.java
│ │ └── CodingConsole.java
│ │ └── ClasspathPropertiesProvider.java
├── README.txt
└── pom.xml
├── gp.sh
├── softwaremill-cdi
└── src
│ ├── test
│ ├── resources
│ │ ├── conftest.conf
│ │ └── hibernate.test.cfg.xml
│ └── java
│ │ └── com
│ │ └── softwaremill
│ │ └── common
│ │ └── cdi
│ │ ├── objectservice
│ │ ├── A.java
│ │ ├── auto
│ │ │ ├── IAuto.java
│ │ │ ├── MySpecialString.java
│ │ │ ├── ExecutionMock.java
│ │ │ ├── MyString.java
│ │ │ ├── AutoMyString.java
│ │ │ └── AutoString.java
│ │ ├── Service1.java
│ │ ├── Service2.java
│ │ ├── AbstractService3.java
│ │ ├── Service3.java
│ │ ├── C.java
│ │ ├── B.java
│ │ ├── Service1B.java
│ │ ├── Service1C.java
│ │ ├── Service3B.java
│ │ ├── Service3C.java
│ │ ├── Service2C.java
│ │ └── Service2B.java
│ │ ├── autofactory
│ │ ├── qualifier
│ │ │ ├── QualifiedDependency.java
│ │ │ ├── ExampleStringQualifier.java
│ │ │ └── PriceCalculatorQualifiedDependencyImpl.java
│ │ ├── Discounts.java
│ │ ├── instance
│ │ │ ├── InstanceBean.java
│ │ │ ├── InstanceBean2.java
│ │ │ └── InjectDataAndInstanceConstructor.java
│ │ ├── BulkOrderDiscounts.java
│ │ ├── PriceCalculator.java
│ │ ├── Product.java
│ │ ├── TotalPriceCalculator.java
│ │ ├── producer
│ │ │ ├── ExampleProductQualifier.java
│ │ │ └── ExamplePriceCalculatorProducer.java
│ │ ├── mixed
│ │ │ ├── PriceCalculatorMixedConstructorImpl.java
│ │ │ └── AutoFactoryMixedConstructorTest.java
│ │ ├── logger
│ │ │ ├── InjectDataAndLoggerField.java
│ │ │ └── InjectDataAndLoggerConstructor.java
│ │ ├── field
│ │ │ ├── PriceCalculatorFieldInjectionImpl.java
│ │ │ ├── AutoFactoryFieldInjectionTest.java
│ │ │ └── TotalPriceCalculatorFixedInjectionImpl.java
│ │ └── multipleconstructors
│ │ │ └── BeanWithAdditionalDefaultConstructor.java
│ │ ├── security
│ │ ├── SecureBeanGlobal.java
│ │ ├── SecureResultBean.java
│ │ ├── SecureBeanStacked.java
│ │ ├── SecureBeanSecureVar.java
│ │ ├── SecureBeanSecureVarExp.java
│ │ ├── SecureBeanDirect.java
│ │ ├── StringHolder.java
│ │ ├── SecureBeanCompoundContextual.java
│ │ ├── NoAccess.java
│ │ ├── AccessIfVar1Set.java
│ │ ├── AllowWithFlagsBean.java
│ │ └── SecureResultTest.java
│ │ ├── el
│ │ └── StringHoldingBean.java
│ │ ├── interceptor
│ │ └── BeanToIntercept.java
│ │ ├── persistence
│ │ ├── MockEntityManagerProducers.java
│ │ ├── EntityWithLazySubentity.java
│ │ └── AbstractHibernateTest.java
│ │ ├── util
│ │ └── ArquillianUtil.java
│ │ └── conf
│ │ └── ConfValueTest.java
│ └── main
│ ├── resources
│ └── META-INF
│ │ ├── services
│ │ └── javax.enterprise.inject.spi.Extension
│ │ └── beans.xml
│ └── java
│ └── com
│ └── softwaremill
│ └── common
│ └── cdi
│ ├── el
│ ├── ELEvaluator.java
│ ├── ELEvaluatorUtil.java
│ ├── ELEvaluatorProducer.java
│ ├── FacesContextELEvaluator.java
│ └── AbstractELEvaluator.java
│ ├── security
│ ├── LoginBean.java
│ ├── SecurityConditionException.java
│ ├── SecureBinding.java
│ ├── AllowWithFlag.java
│ ├── Secure.java
│ ├── SecureVar.java
│ ├── InterceptSecure.java
│ ├── SecurityFlags.java
│ ├── SecureResult.java
│ └── SecurityResultInterceptor.java
│ ├── objectservice
│ ├── OS.java
│ ├── auto
│ │ ├── OS.java
│ │ ├── AutoOSException.java
│ │ └── OSImpl.java
│ ├── OSP.java
│ └── extension
│ │ ├── PureWildcardType.java
│ │ └── OSPImpl.java
│ ├── autofactory
│ ├── extension
│ │ ├── parameter
│ │ │ ├── converter
│ │ │ │ └── ConstructorToParameterValuesConverter.java
│ │ │ ├── ParameterValue.java
│ │ │ └── FactoryParameterParameterValue.java
│ │ ├── QualifierAnnotationsFilter.java
│ │ ├── MethodParameterIndexer.java
│ │ └── AutoFactoryExtension.java
│ ├── FactoryParameter.java
│ └── CreatedWith.java
│ ├── transaction
│ ├── Transactional.java
│ └── TransactionTimeout.java
│ ├── persistence
│ ├── Writeable.java
│ ├── ReadOnly.java
│ ├── QueryCreator.java
│ ├── EntityManagerUtil.java
│ └── EntityManagerFactoryProducer.java
│ ├── config
│ └── Configuration.java
│ ├── conf
│ ├── ConfValue.java
│ └── ConfValueProducer.java
│ ├── interceptor
│ ├── NullToEmptyStringParams.java
│ └── NullToEmptyStringParamsInterceptor.java
│ ├── logger
│ └── LoggerProducer.java
│ ├── sysprops
│ └── SystemProperty.java
│ └── validation
│ ├── NoSpecialCharsValidator.java
│ ├── NoSpecialChars.java
│ └── Length.java
├── softwaremill-backup
├── src
│ ├── test
│ │ └── resources
│ │ │ └── backuptest.conf
│ └── main
│ │ └── java
│ │ └── com
│ │ └── softwaremill
│ │ └── common
│ │ └── backup
│ │ └── SimpleDBRegion.java
└── scripts
│ ├── restore_sdb.sh
│ ├── backup_conf.sh
│ ├── backup_sdb_and_upload.sh
│ └── backup_mysql_and_upload.sh
├── softwaremill-debug
└── src
│ └── main
│ ├── resources
│ └── META-INF
│ │ ├── services
│ │ └── javax.enterprise.inject.spi.Extension
│ │ └── beans.xml
│ └── java
│ └── com
│ └── softwaremill
│ └── common
│ └── debug
│ └── timing
│ ├── Timed.java
│ ├── TimingOutputFilter.java
│ ├── TimingInterceptor.java
│ └── TimingProxy.java
├── softwaremill-test
├── softwaremill-test-db
│ ├── src
│ │ ├── main
│ │ │ ├── resources
│ │ │ │ ├── jndi.properties
│ │ │ │ ├── bitronix-default-config.properties
│ │ │ │ └── hibernate.test.cfg.xml
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── softwaremill
│ │ │ │ └── common
│ │ │ │ └── dbtest
│ │ │ │ ├── util
│ │ │ │ ├── SqlFileResolver.java
│ │ │ │ └── DbMode.java
│ │ │ │ └── UtxDependencyProvider.java
│ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── softwaremill
│ │ │ └── common
│ │ │ └── dbtest
│ │ │ ├── TestOfDBTest.sql
│ │ │ ├── EntityDAO.java
│ │ │ ├── Entity.java
│ │ │ ├── TestEntity1Reader.java
│ │ │ ├── TestEntity1Manager.java
│ │ │ └── util
│ │ │ └── SqlFileResolverTest.java
│ └── README.md
├── softwaremill-test-server
│ └── src
│ │ └── main
│ │ ├── resources
│ │ ├── dummy.keystore
│ │ └── logback.xml
│ │ └── java
│ │ └── com
│ │ └── softwaremill
│ │ └── common
│ │ └── testserver
│ │ └── Responder.java
├── softwaremill-test-ui-web
│ ├── README.md
│ └── src
│ │ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── softwaremill
│ │ │ └── common
│ │ │ └── test
│ │ │ └── web
│ │ │ └── selenium
│ │ │ └── screenshots
│ │ │ ├── AnTest.java
│ │ │ └── AnSeleniumTest.java
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── softwaremill
│ │ └── common
│ │ └── test
│ │ └── web
│ │ ├── jboss
│ │ ├── SysoutLog.java
│ │ ├── Deployment.java
│ │ ├── server
│ │ │ ├── JBossAS.java
│ │ │ └── JBossASProvider.java
│ │ └── DeployementProperties.java
│ │ ├── selenium
│ │ ├── screenshots
│ │ │ └── Screenshotter.java
│ │ ├── SMLSelenium.java
│ │ └── SeleniumBrowserProperties.java
│ │ └── email
│ │ ├── EmailHeader.java
│ │ └── AbstractEmailServerRunner.java
├── softwaremill-test-ui-swing
│ ├── README.MD
│ ├── src
│ │ ├── main
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── softwaremill
│ │ │ │ └── test
│ │ │ │ └── swing
│ │ │ │ ├── AbstractGUITest.java
│ │ │ │ ├── TeamCityScreenShotOnFailureListener.java
│ │ │ │ └── FileNameBuilder.java
│ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── softwaremill
│ │ │ └── test
│ │ │ └── swing
│ │ │ └── AppTest.java
│ └── pom.xml
├── softwaremill-test-arquillian
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── softwaremill
│ │ └── common
│ │ └── arquillian
│ │ ├── ArchiveUtil.java
│ │ ├── ManifestUtil.java
│ │ └── BetterArquillian.java
├── softwaremill-test-util
│ ├── src
│ │ ├── main
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── softwaremill
│ │ │ │ └── common
│ │ │ │ └── test
│ │ │ │ └── util
│ │ │ │ ├── Execution.java
│ │ │ │ ├── ExtMockito.java
│ │ │ │ ├── reorder
│ │ │ │ ├── LastTest.java
│ │ │ │ ├── TestOrder.java
│ │ │ │ └── FirstTest.java
│ │ │ │ └── MessageWaiter.java
│ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── softwaremill
│ │ │ └── common
│ │ │ └── test
│ │ │ └── util
│ │ │ ├── ExtMockitoTest.java
│ │ │ ├── MockitoTestNGListenerTest.java
│ │ │ └── ExecutionTest.java
│ └── README.md
└── pom.xml
├── .gitignore
├── softwaremill-sqs
├── src
│ ├── test
│ │ └── resources
│ │ │ └── sqs.conf
│ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── softwaremill
│ │ │ └── common
│ │ │ ├── task
│ │ │ ├── TaskExecutor.java
│ │ │ ├── Task.java
│ │ │ ├── OneTimeTask.java
│ │ │ └── ExecuteWithRequestContext.java
│ │ │ └── sqs
│ │ │ ├── task
│ │ │ └── SQSTaskTimer.java
│ │ │ ├── exception
│ │ │ └── SQSRuntimeException.java
│ │ │ ├── email
│ │ │ ├── SendEmailTaskExecutor.java
│ │ │ └── SendEmailTask.java
│ │ │ ├── util
│ │ │ ├── AttachmentDescription.java
│ │ │ └── SQSAnswer.java
│ │ │ ├── ReceivedMessage.java
│ │ │ ├── MessageId.java
│ │ │ └── ReceiptHandle.java
│ │ └── resources
│ │ └── META-INF
│ │ └── beans.xml
└── README.md
├── softwaremill-scripts
└── jsf-view-generator
│ ├── README.md
│ └── pom.xml
├── softwaremill-util
├── src
│ ├── test
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── softwaremill
│ │ │ │ └── common
│ │ │ │ └── util
│ │ │ │ ├── dependency
│ │ │ │ ├── FooAnnotatedClass.java
│ │ │ │ ├── RequestScopedService.java
│ │ │ │ ├── TestQualifier.java
│ │ │ │ └── AnotherTestQualifier.java
│ │ │ │ ├── RichStringTest.java
│ │ │ │ └── stringsorting
│ │ │ │ └── ByteByByteStringComparatorTest.java
│ │ └── resources
│ │ │ ├── simple.etemplate
│ │ │ └── advanced.etemplate
│ └── main
│ │ └── java
│ │ └── com
│ │ └── softwaremill
│ │ └── common
│ │ └── util
│ │ ├── persistance
│ │ └── Identifiable.java
│ │ ├── Sleeper.java
│ │ ├── time
│ │ ├── Clock.java
│ │ ├── RealTimeClock.java
│ │ └── FixtureTimeClock.java
│ │ ├── InfiniteSleeper.java
│ │ ├── io
│ │ ├── FileFilenameFilter.java
│ │ ├── DirFilenameFilter.java
│ │ ├── InputStreamInputSupplier.java
│ │ └── Shell.java
│ │ ├── dependency
│ │ ├── DependencyProvider.java
│ │ └── GlobalDependencyProvider.java
│ │ ├── SecsToMills.java
│ │ ├── templates
│ │ └── TemplateContentData.java
│ │ ├── stringsorting
│ │ ├── ByteByByteStringComparator.java
│ │ └── SortedCharsToConsecutiveCharsAssigner.java
│ │ ├── IncrementalSleeper.java
│ │ ├── RichList.java
│ │ ├── tuples
│ │ └── LexicographicPair.java
│ │ ├── NameValuePairBuilder.java
│ │ ├── validation
│ │ └── NotJustWhitespace.java
│ │ └── system
│ │ └── ProcessKiller.java
└── README.md
├── softwaremill-paypal
├── src
│ ├── main
│ │ └── java
│ │ │ └── com
│ │ │ └── softwaremill
│ │ │ └── common
│ │ │ └── paypal
│ │ │ ├── process
│ │ │ ├── status
│ │ │ │ ├── VerificationException.java
│ │ │ │ ├── PayPalStatusVerifier.java
│ │ │ │ └── PayPalStatus.java
│ │ │ └── processors
│ │ │ │ ├── VerifiedPayPalProcessor.java
│ │ │ │ ├── PayPalProcessor.java
│ │ │ │ ├── InvalidPayPalProcessor.java
│ │ │ │ ├── UnknownPayPalProcessor.java
│ │ │ │ └── AbstractPayPalProcessor.java
│ │ │ └── button
│ │ │ └── PaypalCartItem.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── softwaremill
│ │ └── common
│ │ └── paypal
│ │ └── process
│ │ ├── TestErrorHandler.java
│ │ ├── processors
│ │ └── MockVerifiedPayPalProcessor.java
│ │ └── status
│ │ └── MockStatusVerifier.java
└── pom.xml
└── softwaremill-faces
└── src
└── main
├── resources
└── META-INF
│ ├── beans.xml
│ └── smlComponents.taglib.xml
└── java
└── com
└── softwaremill
└── common
└── faces
├── navigation
├── Page.java
├── CurrentPage.java
└── ViewIdPage.java
├── validator
├── DelegatingValidator.java
└── AbstractDelgatingValidator.java
├── messages
└── FacesMessagesListener.java
├── transaction
└── TransactionExceptionObserver.java
└── fileupload
└── FileUpload.java
/softwaremill-conf/src/test/resources/test2.conf:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/gp.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | git fetch
3 | git rebase origin
4 | git push
5 |
6 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/resources/conftest.conf:
--------------------------------------------------------------------------------
1 | key1=value1
2 | key2=value2
--------------------------------------------------------------------------------
/softwaremill-conf/src/test/resources/test1.conf:
--------------------------------------------------------------------------------
1 | a=b
2 | c=d
3 | x=encoded.AjVEqbmwIvk=
--------------------------------------------------------------------------------
/softwaremill-backup/src/test/resources/backuptest.conf:
--------------------------------------------------------------------------------
1 | AWSAccessKeyId=${AWSAccessKeyId}
2 | SecretAccessKey=${SecretAccessKey}
--------------------------------------------------------------------------------
/softwaremill-debug/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension:
--------------------------------------------------------------------------------
1 | com.softwaremill.common.debug.timing.TimingExtension
2 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-db/src/main/resources/jndi.properties:
--------------------------------------------------------------------------------
1 | java.naming.factory.initial=bitronix.tm.jndi.BitronixInitialContextFactory
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | tmp
2 | temp
3 | log
4 | target
5 | .classpath
6 | .project
7 | .settings
8 | *~
9 | *.tmp
10 | *.iml
11 | *.ipr
12 | *.iws
13 | .idea
14 |
15 | # Mac specific
16 | .DS_Store
17 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-db/src/main/resources/bitronix-default-config.properties:
--------------------------------------------------------------------------------
1 | bitronix.tm.journal.disk.logPart1Filename=target/btm1.tlog
2 | bitronix.tm.journal.disk.logPart2Filename=target/btm2.tlog
3 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-server/src/main/resources/dummy.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/softwaremill/softwaremill-common/HEAD/softwaremill-test/softwaremill-test-server/src/main/resources/dummy.keystore
--------------------------------------------------------------------------------
/softwaremill-sqs/src/test/resources/sqs.conf:
--------------------------------------------------------------------------------
1 | AWSAccessKeyId=${AWSAccessKeyId}
2 | SecretAccessKey=${SecretAccessKey}
3 | smtpHost=localhost
4 | smtpPort=9025
5 | queue=sqs-email-test
6 | from=test@example.org
7 | encoding=UTF-8
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-db/src/test/java/com/softwaremill/common/dbtest/TestOfDBTest.sql:
--------------------------------------------------------------------------------
1 | insert into test_entity_1(id, data_c) values (0, 'data1');
2 | insert into test_entity_1(id, data_c) values (1, 'data2');
3 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/A.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public abstract class A {
7 | }
8 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/autofactory/qualifier/QualifiedDependency.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory.qualifier;
2 |
3 | @ExampleStringQualifier
4 | public class QualifiedDependency {
5 | }
6 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-ui-web/README.md:
--------------------------------------------------------------------------------
1 | Maven dependency:
2 |
3 |
4 | com.softwaremill.common
5 | softwaremill-test-ui-web
6 | 18
7 |
8 |
--------------------------------------------------------------------------------
/softwaremill-scripts/jsf-view-generator/README.md:
--------------------------------------------------------------------------------
1 | Quick and dirty Scala script to create simple JSF view of fields of entity. It is necessary to add .jar with entity to the classpath (add it as dependency to pom.xml, and your IDE should do the rest).
2 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/auto/IAuto.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice.auto;
2 |
3 | @OS
4 | public interface IAuto {
5 |
6 | void doSomething(String bom, T object, Integer bim);
7 | }
8 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-ui-swing/README.MD:
--------------------------------------------------------------------------------
1 | Maven dependency:
2 |
3 |
4 | com.softwaremill.common
5 | softwaremill-test-ui-swing
6 | ${current.version}
7 |
8 |
--------------------------------------------------------------------------------
/softwaremill-util/src/test/java/com/softwaremill/common/util/dependency/FooAnnotatedClass.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util.dependency;
2 |
3 | /**
4 | * Class to get the "real" qualifier from
5 | */
6 | @TestQualifier
7 | public class FooAnnotatedClass {
8 | }
9 |
--------------------------------------------------------------------------------
/softwaremill-util/src/test/java/com/softwaremill/common/util/dependency/RequestScopedService.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util.dependency;
2 |
3 | import javax.enterprise.context.RequestScoped;
4 |
5 | @RequestScoped
6 | public class RequestScopedService {
7 | }
8 |
--------------------------------------------------------------------------------
/softwaremill-sqs/src/main/java/com/softwaremill/common/task/TaskExecutor.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.task;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public interface TaskExecutor> {
7 | void execute(T task);
8 | }
9 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/Service1.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public interface Service1 extends OS {
7 | Object get();
8 | }
9 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/Service2.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public interface Service2 extends OS {
7 | Object get();
8 | }
9 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/security/SecureBeanGlobal.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | @Secure("#{false}")
7 | public class SecureBeanGlobal {
8 | public void method1() { }
9 | }
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/AbstractService3.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public abstract class AbstractService3 implements Service3 {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-ui-web/src/test/java/com/softwaremill/common/test/web/selenium/screenshots/AnTest.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.test.web.selenium.screenshots;
2 |
3 | /**
4 | * It isn't a real test class, it's used in {@link FailureTestListenerTest}
5 | */
6 | public class AnTest {}
7 |
--------------------------------------------------------------------------------
/softwaremill-util/src/main/java/com/softwaremill/common/util/persistance/Identifiable.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util.persistance;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public interface Identifiable {
7 | T getId();
8 | void setId(T id);
9 | }
10 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/autofactory/Discounts.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class Discounts {
7 | public int getNormalDiscount() {
8 | return 10;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/security/SecureResultBean.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class SecureResultBean {
7 | @SecureResult("#{result == 'a'}")
8 | public String method1(String p) { return p; }
9 | }
--------------------------------------------------------------------------------
/softwaremill-util/src/test/resources/simple.etemplate:
--------------------------------------------------------------------------------
1 | # This is a comment line - begins with #
2 | #
3 | # Simple template: subject, no arguments
4 | #
5 | # Subject can be putted in a line prefixed with %subject% - rest of line is trimmed
6 | # Rest of file is email body
7 |
8 | %subject% Hello World!
9 |
10 | This is a sample email.
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/autofactory/instance/InstanceBean.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory.instance;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class InstanceBean {
7 | public String getData() {
8 | return "a";
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/autofactory/instance/InstanceBean2.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory.instance;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class InstanceBean2 {
7 | public String getData() {
8 | return "b";
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/security/SecureBeanStacked.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class SecureBeanStacked {
7 | public void method1() { }
8 |
9 | @NoAccess
10 | public void method2() { }
11 | }
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-db/src/test/java/com/softwaremill/common/dbtest/EntityDAO.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.dbtest;
2 |
3 | /**
4 | * @author Maciej Bilas
5 | * @since 15/12/11 12:45
6 | */
7 | public interface EntityDAO {
8 | Entity persist(Entity entity);
9 |
10 | Entity reload(Entity entity);
11 | }
12 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/security/SecureBeanSecureVar.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class SecureBeanSecureVar {
7 | @Secure("#{var1 == true}")
8 | public void method1(@SecureVar("var1") boolean var1) { }
9 | }
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/autofactory/BulkOrderDiscounts.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class BulkOrderDiscounts {
7 | public int getDiscountForBulkOrderSize(int size) {
8 | return size/2;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/softwaremill-sqs/src/main/java/com/softwaremill/common/task/Task.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.task;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * @author Adam Warski (adam at warski dot org)
7 | */
8 | public interface Task> extends Serializable {
9 | Class extends TaskExecutor> getExecutorBeanClass();
10 | }
11 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/el/StringHoldingBean.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.el;
2 |
3 | import javax.inject.Named;
4 |
5 | /**
6 | * @author Adam Warski (adam at warski dot org)
7 | */
8 | @Named
9 | public class StringHoldingBean {
10 | public String getValue() {
11 | return "test value";
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-ui-web/src/main/java/com/softwaremill/common/test/web/jboss/SysoutLog.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.test.web.jboss;
2 |
3 | /**
4 | * @author Pawel Wrzeszcz (pawel [at] softwaremill . com)
5 | */
6 | public class SysoutLog {
7 |
8 | public void info(String msg) {
9 | System.out.println("--- " + msg);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/Service3.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice;
2 |
3 | /**
4 | * A service for which implementations inherit from an abtract service.
5 | * @author Adam Warski (adam at warski dot org)
6 | */
7 | public interface Service3 extends OS {
8 | Object get();
9 | }
10 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/security/SecureBeanSecureVarExp.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class SecureBeanSecureVarExp {
7 | @Secure("#{var1 == 'a'}")
8 | public void method1(@SecureVar(value = "var1", exp = "#{p.content}") StringHolder sh) { }
9 | }
--------------------------------------------------------------------------------
/softwaremill-util/src/main/java/com/softwaremill/common/util/Sleeper.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util;
2 |
3 | public class Sleeper {
4 | public static void sleepFor(long millis) {
5 | try {
6 | Thread.sleep(millis);
7 | } catch (InterruptedException e) {
8 | throw new RuntimeException(e);
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/softwaremill-util/src/main/java/com/softwaremill/common/util/time/Clock.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util.time;
2 |
3 | import org.joda.time.DateTime;
4 |
5 | /**
6 | * Interface providing current system time.
7 | */
8 | public interface Clock {
9 |
10 | DateTime currentDateTime();
11 | DateTime currentDateTimeUTC();
12 | long currentTimeMillis();
13 | }
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/security/SecureBeanDirect.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class SecureBeanDirect {
7 | @Secure("#{true}")
8 | public void method1() { }
9 |
10 | @Secure("#{false}")
11 | public void method2() { }
12 | }
13 |
--------------------------------------------------------------------------------
/softwaremill-util/src/main/java/com/softwaremill/common/util/InfiniteSleeper.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util;
2 |
3 | /**
4 | * @author Pawel Wrzeszcz (pawel [at] softwaremill . com)
5 | */
6 | public class InfiniteSleeper {
7 |
8 | public synchronized void sleepInfinitely() throws InterruptedException {
9 | wait(); // Never expected to be notified
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/autofactory/PriceCalculator.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public interface PriceCalculator {
7 | int getFinalPrice();
8 |
9 | interface Factory {
10 | PriceCalculator create(Product product);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-ui-web/src/main/java/com/softwaremill/common/test/web/selenium/screenshots/Screenshotter.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.test.web.selenium.screenshots;
2 |
3 | /**
4 | * Screenshotter
5 | *
6 | * User: szimano
7 | */
8 | public interface Screenshotter {
9 |
10 | /**
11 | * Performs screenshot
12 | */
13 | void doScreenshot();
14 | }
15 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-server/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %d{HH:mm:ss.SSS} %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/auto/MySpecialString.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice.auto;
2 |
3 | /**
4 | * Class that extends MyString for inheritance checks
5 | */
6 | public class MySpecialString extends MyString{
7 |
8 | public MySpecialString(String someString) {
9 | super(someString + "ButVerySpecial");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/softwaremill-conf/src/main/java/com/softwaremill/common/conf/PropertiesProvider.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.conf;
2 |
3 | import com.google.common.collect.ImmutableMap;
4 |
5 | /**
6 | * @author Adam Warski (adam at warski dot org)
7 | */
8 | public interface PropertiesProvider {
9 | ImmutableMap lookupProperties(String name);
10 |
11 | boolean providerAvailable();
12 | }
13 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/auto/ExecutionMock.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice.auto;
2 |
3 | import javax.enterprise.context.ApplicationScoped;
4 | import java.io.Serializable;
5 |
6 | @ApplicationScoped
7 | public class ExecutionMock implements Serializable{
8 |
9 | Integer myStringExecs = 0;
10 |
11 | Integer stringExecs = 0;
12 | }
13 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension:
--------------------------------------------------------------------------------
1 | com.softwaremill.common.cdi.security.SecurityExtension
2 | com.softwaremill.common.cdi.config.ConfigExtension
3 | com.softwaremill.common.cdi.objectservice.extension.ObjectServiceExtension
4 | com.softwaremill.common.cdi.autofactory.extension.AutoFactoryExtension
5 | com.softwaremill.common.cdi.objectservice.auto.AutoObjectServiceExtension
6 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/C.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class C extends A {
7 | private String value;
8 |
9 | public C(String value) {
10 | this.value = value;
11 | }
12 |
13 | public String getValue() {
14 | return value;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/B.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class B extends A {
7 | private Integer value;
8 |
9 | public B(Integer value) {
10 | this.value = value;
11 | }
12 |
13 | public Integer getValue() {
14 | return value;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/el/ELEvaluator.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.el;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | * @author Adam Warski (adam at warski dot org)
7 | */
8 | public interface ELEvaluator {
9 | T evaluate(String expression, Class expectedResultType);
10 |
11 | T evaluate(String expression, Class expectedResultType, Map parameters);
12 | }
13 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/security/LoginBean.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | /**
4 | * Should be implemented by the bean which controls the logged-in status of the user.
5 | * @author Adam Warski (adam at warski dot org)
6 | */
7 | public interface LoginBean {
8 | /**
9 | * @return True iff a user is currently logged in.
10 | */
11 | boolean isLoggedIn();
12 | }
13 |
--------------------------------------------------------------------------------
/softwaremill-conf/README.txt:
--------------------------------------------------------------------------------
1 | # Configuration reader
2 |
3 | Maven dependency:
4 |
5 |
6 | com.softwaremill.common
7 | softwaremill-conf
8 | 5
9 |
10 |
11 | See the javadocs for the [Configuration](/softwaremill/softwaremill-common/blob/master/softwaremill-conf/src/main/java/pl/softwaremill/common/conf/Configuration.java) class.
--------------------------------------------------------------------------------
/softwaremill-paypal/src/main/java/com/softwaremill/common/paypal/process/status/VerificationException.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.paypal.process.status;
2 |
3 | /**
4 | * @Author: lukasz.zuchowski at gmail dot com
5 | * Date: 05.04.12
6 | * Time: 13:18
7 | */
8 | public class VerificationException extends RuntimeException {
9 |
10 | public VerificationException(Throwable cause) {
11 | super(cause);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/softwaremill-backup/scripts/restore_sdb.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ $# -ne 2 ]
4 | then
5 | echo "Usage: restrore_sdb [domain name] [file name]"
6 | exit 1
7 | fi
8 |
9 | # Configuration
10 | ###############
11 |
12 | source backup_conf.sh
13 |
14 | #########
15 |
16 | # Creating backup files
17 | java -cp $SDB_BACKUP_PATH com.softwaremill.common.backup.RunRestore $SIMPLEDB_ACCESS_KEY_ID $SIMPLEDB_SECRET_ACCESS_KEY $SIMPLEDB_REGION $1 $2
18 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/autofactory/Product.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class Product {
7 | private int basePrice;
8 |
9 | public Product(int basePrice) {
10 | this.basePrice = basePrice;
11 | }
12 |
13 | public int getBasePrice() {
14 | return basePrice;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/auto/MyString.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice.auto;
2 |
3 | /**
4 | * String wrapper
5 | */
6 | public class MyString {
7 |
8 | public String someString;
9 |
10 | public MyString(String someString) {
11 | this.someString = someString;
12 | }
13 |
14 | public String getSomeString() {
15 | return someString;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/autofactory/TotalPriceCalculator.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * @author Adam Warski (adam at warski dot org)
7 | */
8 | public interface TotalPriceCalculator {
9 | int getTotalPrice();
10 |
11 | interface Factory {
12 | TotalPriceCalculator create(List products, int specialDiscount);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/security/StringHolder.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class StringHolder {
7 | private final String content;
8 |
9 | public StringHolder(String content) {
10 | this.content = content;
11 | }
12 |
13 | public String getContent() {
14 | return content;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/softwaremill-paypal/src/main/java/com/softwaremill/common/paypal/process/processors/VerifiedPayPalProcessor.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.paypal.process.processors;
2 |
3 | import com.softwaremill.common.paypal.process.status.PayPalStatus;
4 |
5 | public abstract class VerifiedPayPalProcessor extends AbstractPayPalProcessor {
6 |
7 | @Override
8 | public boolean accept(PayPalStatus status) {
9 | return status.isVerified();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/objectservice/OS.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice;
2 |
3 | /**
4 | * A marker interface for services for particular type of objects.
5 | * @author Adam Warski (adam at warski dot org)
6 | */
7 | public interface OS {
8 | /**
9 | * Sets the object, that is being serviced.
10 | * @param serviced The serviced object.
11 | */
12 | void setServiced(T serviced);
13 | }
14 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-ui-web/src/main/java/com/softwaremill/common/test/web/jboss/Deployment.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.test.web.jboss;
2 |
3 | /**
4 | * @author Pawel Wrzeszcz (pawel . wrzeszcz [at] gmail . com)
5 | */
6 | public interface Deployment {
7 | void deploy(String deployDir) throws Exception;
8 |
9 | void undeploy(String deployDir) throws Exception;
10 |
11 | String getWaitForMessage();
12 |
13 | long getWaitMillis();
14 | }
15 |
--------------------------------------------------------------------------------
/softwaremill-sqs/src/main/java/com/softwaremill/common/task/OneTimeTask.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.task;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public interface OneTimeTask> extends Task {
7 | /**
8 | * @return Number of seconds after which the task execution will be retried. Return {@code null} for the default
9 | * interval (30 seconds).
10 | */
11 | Integer getTaskTimeout();
12 | }
13 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/autofactory/extension/parameter/converter/ConstructorToParameterValuesConverter.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory.extension.parameter.converter;
2 |
3 | import com.softwaremill.common.cdi.autofactory.extension.parameter.ParameterValue;
4 |
5 | /**
6 | * @author Adam Warski (adam at warski dot org)
7 | */
8 | public interface ConstructorToParameterValuesConverter {
9 | ParameterValue[] convert();
10 | }
11 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/security/SecureBeanCompoundContextual.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | @Secure("#{var3 == true}")
7 | public class SecureBeanCompoundContextual {
8 | @AccessIfVar1Set
9 | @Secure("#{var2 == true}")
10 | public void method1(@SecureVar("var1") boolean var1, @SecureVar("var2") boolean var2, @SecureVar("var3") boolean var3) { }
11 | }
--------------------------------------------------------------------------------
/softwaremill-paypal/src/main/java/com/softwaremill/common/paypal/process/status/PayPalStatusVerifier.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.paypal.process.status;
2 |
3 | import com.softwaremill.common.paypal.process.RequestParameters;
4 |
5 | /**
6 | * @Author: lukasz.zuchowski at gmail dot com
7 | * Date: 05.04.12
8 | * Time: 13:16
9 | */
10 | public interface PayPalStatusVerifier {
11 |
12 | public PayPalStatus verify(String url, RequestParameters requestParameters);
13 | }
14 |
--------------------------------------------------------------------------------
/softwaremill-sqs/src/main/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/softwaremill-debug/src/main/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/softwaremill-faces/src/main/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-server/src/main/java/com/softwaremill/common/testserver/Responder.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.testserver;
2 |
3 | import javax.servlet.http.HttpServletRequest;
4 | import javax.servlet.http.HttpServletResponse;
5 | import java.io.IOException;
6 |
7 | public interface Responder {
8 |
9 | boolean canRespond(HttpServletRequest request);
10 |
11 | void respond(HttpServletRequest request, HttpServletResponse response) throws IOException;
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/softwaremill-util/src/test/resources/advanced.etemplate:
--------------------------------------------------------------------------------
1 | # Advanced template: some parameters used
2 | #
3 | # {0} - username
4 | # {1} - email
5 | # {2} - organization name
6 | # {3} - organization subdomain
7 |
8 |
9 | %subject% Welcome to Company!
10 |
11 | Welcome {0},
12 | You have registered in our service your organization: {2}.
13 | Your new e-service can be accessed on http://{3}.example.org
14 | Your account data:
15 | Username: {0}
16 | Email: {1}
17 |
18 | Best regards,
19 | Company Team
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/objectservice/auto/OS.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice.auto;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.Target;
5 |
6 | import static java.lang.annotation.ElementType.TYPE;
7 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
8 |
9 | /**
10 | * Used to mark interface for Object Service
11 | */
12 | @Target({ TYPE })
13 | @Retention(RUNTIME)
14 | public @interface OS {
15 | }
16 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-arquillian/src/main/java/com/softwaremill/common/arquillian/ArchiveUtil.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.arquillian;
2 |
3 | import org.jboss.shrinkwrap.api.ShrinkWrap;
4 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
5 |
6 | /**
7 | * @author Pawel Wrzeszcz (pawel [at] softwaremill . com)
8 | */
9 | public class ArchiveUtil {
10 |
11 | public static JavaArchive createArchive() {
12 | return ShrinkWrap.create(JavaArchive.class, "test.jar");
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-ui-web/src/main/java/com/softwaremill/common/test/web/jboss/server/JBossAS.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.test.web.jboss.server;
2 |
3 | import java.io.IOException;
4 |
5 | /**
6 | * @author Pawel Wrzeszcz (pawel [at] softwaremill . com)
7 | */
8 | public interface JBossAS {
9 |
10 | Process start() throws Exception;
11 |
12 | void shutdown() throws IOException, InterruptedException;
13 |
14 | String getDeployDir();
15 |
16 | String getServerLogPath();
17 | }
18 |
--------------------------------------------------------------------------------
/softwaremill-faces/src/main/java/com/softwaremill/common/faces/navigation/Page.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.faces.navigation;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public interface Page {
7 | Page redirect();
8 | Page includeViewParams();
9 | Page includeViewParam(String name);
10 | Page includeParam(String name, String value);
11 |
12 | String s();
13 | String getS();
14 |
15 | boolean isRequiresLogin();
16 | String getSecurityEL();
17 | }
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/Service1B.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class Service1B implements Service1 {
7 | private B serviced;
8 |
9 | @Override
10 | public void setServiced(B serviced) {
11 | this.serviced = serviced;
12 | }
13 |
14 | @Override
15 | public Object get() {
16 | return serviced.getValue();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/Service1C.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class Service1C implements Service1 {
7 | private C serviced;
8 |
9 | @Override
10 | public void setServiced(C serviced) {
11 | this.serviced = serviced;
12 | }
13 |
14 | @Override
15 | public Object get() {
16 | return serviced.getValue();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/Service3B.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class Service3B extends AbstractService3 {
7 | private B serviced;
8 |
9 | @Override
10 | public void setServiced(B serviced) {
11 | this.serviced = serviced;
12 | }
13 |
14 | @Override
15 | public Object get() {
16 | return serviced.getValue();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/Service3C.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class Service3C extends AbstractService3 {
7 | private C serviced;
8 |
9 | @Override
10 | public void setServiced(C serviced) {
11 | this.serviced = serviced;
12 | }
13 |
14 | @Override
15 | public Object get() {
16 | return serviced.getValue();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/softwaremill-sqs/src/main/java/com/softwaremill/common/sqs/task/SQSTaskTimer.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.sqs.task;
2 |
3 | import javax.ejb.Local;
4 | import javax.ejb.Timer;
5 |
6 | /**
7 | * Local interface for the task timer.
8 | *
9 | * @author Jaroslaw Kijanowski - jarek@softwaremill.pl
10 | * Date: Aug 24, 2010
11 | */
12 | @Local
13 | public interface SQSTaskTimer {
14 | public void startTimer(int interval);
15 |
16 | public void timeout(Timer timer);
17 |
18 | public void destroyTimer();
19 | }
20 |
--------------------------------------------------------------------------------
/softwaremill-util/src/main/java/com/softwaremill/common/util/io/FileFilenameFilter.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util.io;
2 |
3 | import java.io.File;
4 | import java.io.FilenameFilter;
5 |
6 | /**
7 | * A filename filter which accepts only files.
8 | * @author Adam Warski (adam at warski dot org)
9 | */
10 | public class FileFilenameFilter implements FilenameFilter {
11 | @Override
12 | public boolean accept(File dir, String name) {
13 | return new RichFile(dir).createChildFile(name).isFile();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-db/src/main/java/com/softwaremill/common/dbtest/util/SqlFileResolver.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.dbtest.util;
2 |
3 | /**
4 | * @author Pawel Wrzeszcz (pawel . wrzeszcz [at] gmail . com)
5 | */
6 | public class SqlFileResolver {
7 |
8 | private Class clazz;
9 |
10 | public SqlFileResolver(Class clazz) {
11 | this.clazz = clazz;
12 | }
13 |
14 | public String getSqlFilePath() {
15 | return clazz.getPackage().getName().replace(".","/") + "/" + clazz.getSimpleName() + ".sql";
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/softwaremill-util/src/main/java/com/softwaremill/common/util/io/DirFilenameFilter.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util.io;
2 |
3 | import java.io.File;
4 | import java.io.FilenameFilter;
5 |
6 | /**
7 | * A filename filter which accepts only directories.
8 | * @author Adam Warski (adam at warski dot org)
9 | */
10 | public class DirFilenameFilter implements FilenameFilter {
11 | @Override
12 | public boolean accept(File dir, String name) {
13 | return new RichFile(dir).createChildFile(name).isDirectory();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/transaction/Transactional.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.transaction;
2 |
3 | import javax.interceptor.InterceptorBinding;
4 | import java.lang.annotation.*;
5 |
6 | /**
7 | * Surrounds a method call with a transaction, if one is not yet running.
8 | * @author Adam Warski (adam at warski dot org)
9 | */
10 | @Inherited
11 | @InterceptorBinding
12 | @Target({ElementType.TYPE, ElementType.METHOD})
13 | @Retention(RetentionPolicy.RUNTIME)
14 | public @interface Transactional {
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/interceptor/BeanToIntercept.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.interceptor;
2 |
3 | /**
4 | * @author Pawel Wrzeszcz (pawel [at] softwaremill . com)
5 | */
6 | public class BeanToIntercept {
7 |
8 | @NullToEmptyStringParams
9 | public String[] method(String param1, String param2) {
10 | return new String[] {param1, param2};
11 | }
12 |
13 | @NullToEmptyStringParams
14 | public Object[] method2(Object param1, String param2) {
15 | return new Object[] {param1, param2};
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/security/NoAccess.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * @author Adam Warski (adam at warski dot org)
10 | */
11 | @Target({ ElementType.TYPE, ElementType.METHOD })
12 | @Retention(RetentionPolicy.RUNTIME)
13 | @SecureBinding
14 | @Secure("#{false}")
15 | public @interface NoAccess {
16 | }
17 |
--------------------------------------------------------------------------------
/softwaremill-paypal/src/main/java/com/softwaremill/common/paypal/process/processors/PayPalProcessor.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.paypal.process.processors;
2 |
3 | import com.softwaremill.common.paypal.process.PayPalParameters;
4 | import com.softwaremill.common.paypal.process.status.PayPalStatus;
5 |
6 | public interface PayPalProcessor {
7 |
8 | boolean accept(PayPalStatus status);
9 |
10 | void process(PayPalStatus status, PayPalParameters parameters);
11 |
12 | boolean isError();
13 |
14 | String getErrorMessage();
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/persistence/Writeable.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.persistence;
2 |
3 | import javax.inject.Qualifier;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.*;
8 | import static java.lang.annotation.RetentionPolicy.*;
9 |
10 | /**
11 | * @author Adam Warski (adam at warski dot org)
12 | */
13 | @Qualifier
14 | @Retention(RUNTIME)
15 | @Target({TYPE, METHOD, FIELD, PARAMETER})
16 | public @interface Writeable {
17 | }
--------------------------------------------------------------------------------
/softwaremill-conf/src/main/java/com/softwaremill/common/conf/Config.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.conf;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | * Created by Pawel Stawicki on Feb 24, 2011 12:20:43 PM
7 | */
8 | public interface Config extends Map {
9 |
10 | V get(K key, V defaultValue);
11 |
12 | int getAsInt(K key, int defaultValue);
13 |
14 | double getAsDouble(K key, double defaultValue);
15 |
16 | boolean getAsBoolean(K key, boolean defaultValue);
17 |
18 | long getAsLong(K key, long defaultValue);
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/persistence/ReadOnly.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.persistence;
2 |
3 | import javax.inject.Qualifier;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.*;
8 | import static java.lang.annotation.RetentionPolicy.*;
9 |
10 | /**
11 | * @author Adam Warski (adam at warski dot org)
12 | */
13 | @Qualifier
14 | @Retention(RUNTIME)
15 | @Target({TYPE, METHOD, FIELD, PARAMETER})
16 | public @interface ReadOnly {
17 | }
18 |
--------------------------------------------------------------------------------
/softwaremill-util/src/test/java/com/softwaremill/common/util/dependency/TestQualifier.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util.dependency;
2 |
3 | import javax.inject.Qualifier;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.*;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /**
11 | * Qualifier used for tests
12 | */
13 | @Qualifier
14 | @Retention(RUNTIME)
15 | @Target({TYPE, METHOD, FIELD, PARAMETER})
16 | public @interface TestQualifier {
17 | }
18 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/security/AccessIfVar1Set.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * @author Adam Warski (adam at warski dot org)
10 | */
11 | @Target({ ElementType.TYPE, ElementType.METHOD })
12 | @Retention(RetentionPolicy.RUNTIME)
13 | @SecureBinding
14 | @Secure("#{var1 == true}")
15 | public @interface AccessIfVar1Set {
16 | }
--------------------------------------------------------------------------------
/softwaremill-util/src/test/java/com/softwaremill/common/util/dependency/AnotherTestQualifier.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util.dependency;
2 |
3 | import javax.inject.Qualifier;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.*;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /**
11 | * Qualifier used for tests
12 | */
13 | @Qualifier
14 | @Retention(RUNTIME)
15 | @Target({TYPE, METHOD, FIELD, PARAMETER})
16 | public @interface AnotherTestQualifier {
17 | }
18 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/config/Configuration.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.config;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.Target;
5 |
6 | import static java.lang.annotation.ElementType.TYPE;
7 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
8 |
9 | /**
10 | * Mark simple any class as configuration class
11 | * User: krzysztof.grajek 'at' googlemail.com
12 | * Date: 17/05/2012
13 | */
14 | @Retention(RUNTIME)
15 | @Target({TYPE})
16 | public @interface Configuration {
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/auto/AutoMyString.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice.auto;
2 |
3 | import javax.inject.Inject;
4 |
5 | @OSImpl
6 | public class AutoMyString implements IAuto {
7 |
8 | ExecutionMock execMock;
9 |
10 | @Inject
11 | public AutoMyString(ExecutionMock execMock) {
12 | this.execMock = execMock;
13 | }
14 |
15 | @Override
16 | public void doSomething(String bim, MyString object, Integer bom) {
17 | execMock.myStringExecs += 1;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/softwaremill-debug/src/main/java/com/softwaremill/common/debug/timing/Timed.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.debug.timing;
2 |
3 | import javax.interceptor.InterceptorBinding;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | /**
10 | * @author Adam Warski (adam at warski dot org)
11 | */
12 | @InterceptorBinding
13 | @Target({ ElementType.TYPE, ElementType.METHOD })
14 | @Retention(RetentionPolicy.RUNTIME)
15 | public @interface Timed {
16 | }
17 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/autofactory/qualifier/ExampleStringQualifier.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory.qualifier;
2 |
3 | import javax.inject.Qualifier;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | @Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER })
10 | @Retention(RetentionPolicy.RUNTIME)
11 | @Qualifier
12 | public @interface ExampleStringQualifier {
13 | }
14 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/objectservice/auto/AutoOSException.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice.auto;
2 |
3 | public class AutoOSException extends RuntimeException {
4 |
5 | public AutoOSException() {
6 | super();
7 | }
8 |
9 | public AutoOSException(String message) {
10 | super(message);
11 | }
12 |
13 | public AutoOSException(String message, Throwable cause) {
14 | super(message, cause);
15 | }
16 |
17 | public AutoOSException(Throwable cause) {
18 | super(cause);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/softwaremill-util/src/main/java/com/softwaremill/common/util/dependency/DependencyProvider.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util.dependency;
2 |
3 | import java.lang.annotation.Annotation;
4 |
5 | /**
6 | * @author Adam Warski (adam at warski dot org)
7 | */
8 | public interface DependencyProvider {
9 | /**
10 | * @param cls Class of the dependency.
11 | * @param qualifiers Qualifiers of the dependency.
12 | * @return Dependency with the given class and qualifiers or {@code null} if no dependency is found.
13 | */
14 | T inject(Class cls, Annotation... qualifiers);
15 | }
16 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/conf/ConfValue.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.conf;
2 |
3 | import javax.enterprise.util.Nonbinding;
4 | import javax.inject.Qualifier;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | import static java.lang.annotation.ElementType.*;
10 |
11 | @Qualifier
12 | @Retention(RetentionPolicy.RUNTIME)
13 | @Target({METHOD, FIELD, PARAMETER, TYPE})
14 | public @interface ConfValue {
15 | @Nonbinding String confName();
16 | @Nonbinding String confKey();
17 | }
18 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/security/AllowWithFlagsBean.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class AllowWithFlagsBean {
7 | @AllowWithFlag("flag1")
8 | @Secure("#{false}")
9 | public void testSingleFlagOnly() { }
10 |
11 | @AllowWithFlag({ "flag1", "flag2" })
12 | @Secure("#{false}")
13 | public void testDoubleFlagOnly() { }
14 |
15 | @AllowWithFlag("flag1")
16 | @Secure("#{var1}")
17 | public void testFlagWithSecure(@SecureVar("var1") boolean var1) { }
18 | }
19 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/autofactory/FactoryParameter.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.Target;
5 |
6 | import static java.lang.annotation.ElementType.*;
7 | import static java.lang.annotation.RetentionPolicy.*;
8 |
9 | /**
10 | * Specifies that the annotated constructor parameter should map to a parameter of the factory method.
11 | *
12 | * @author Adam Warski (adam at warski dot org)
13 | */
14 | @Target({ PARAMETER })
15 | @Retention(RUNTIME)
16 | public @interface FactoryParameter {
17 | }
18 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-ui-swing/src/main/java/com/softwaremill/test/swing/AbstractGUITest.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.test.swing;
2 |
3 | import org.assertj.swing.annotation.GUITest;
4 | import org.testng.annotations.Listeners;
5 |
6 | @GUITest
7 | @Listeners({TeamCityScreenShotOnFailureListener.class})
8 | public class AbstractGUITest {
9 |
10 | private GuiScreenShotTaker screenShot;
11 |
12 | protected AbstractGUITest() {
13 | screenShot = new GuiScreenShotTaker();
14 | }
15 |
16 | protected void screenShot() {
17 | screenShot.take(getClass().getName());
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/objectservice/auto/OSImpl.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice.auto;
2 |
3 | import javax.inject.Qualifier;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.TYPE;
8 | import static java.lang.annotation.ElementType.FIELD;
9 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
10 |
11 | /**
12 | * Used to mark implementation of Object Service.
13 | */
14 | @Qualifier
15 | @Target({ TYPE, FIELD })
16 | @Retention(RUNTIME)
17 | public @interface OSImpl {
18 | }
19 |
--------------------------------------------------------------------------------
/softwaremill-conf/src/main/java/com/softwaremill/common/conf/SystemPropertiesMapWrapper.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.conf;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | * Map Wrapper returning System Property if value is null
7 | */
8 | public class SystemPropertiesMapWrapper extends MapWrapper {
9 |
10 | public SystemPropertiesMapWrapper(Map props) {
11 | super(props);
12 | }
13 |
14 | @Override
15 | public String get(Object key) {
16 | final String fromMap = delegate.get(key);
17 | return fromMap != null ? fromMap : System.getProperty(key.toString());
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/softwaremill-backup/scripts/backup_conf.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Configuration
4 | ###############
5 |
6 | # where the backups will be uploaded
7 | S3_ACCESS_KEY_ID=
8 | S3_SECRET_ACCESS_KEY=
9 | S3_BUCKET=
10 | S3_PREFIX=
11 |
12 | # what to backup - SimpleDB
13 | SIMPLEDB_ACCESS_KEY_ID=
14 | SIMPLEDB_SECRET_ACCESS_KEY=
15 | SIMPLEDB_REGION=EUROPE_WEST
16 | # * for all
17 | SIMPLEDB_DOMAINS=
18 |
19 | # what to backup - MySQL
20 | MYSQL_USER=
21 | MYSQL_PASSWORD=
22 | MYSQL_HOST=
23 | # * for all
24 | MYSQL_DB=
25 |
26 | # path to the backup jar
27 | SDB_BACKUP_PATH=softwaremill-backup-45-SNAPSHOT-jar-with-dependencies.jar
28 |
29 | #########
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/autofactory/extension/parameter/ParameterValue.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory.extension.parameter;
2 |
3 | import javax.enterprise.inject.spi.BeanManager;
4 |
5 | /**
6 | * @author Adam Warski (adam at warski dot org)
7 | */
8 | public interface ParameterValue {
9 | /**
10 | * Obtains a value of the argument that this class represents. Either uses the bean manager to obtain it,
11 | * or the provided array of arguments, that were passed to the factory method.
12 | */
13 | Object getValue(BeanManager bm, Object[] factoryParameters);
14 | }
15 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-db/src/test/java/com/softwaremill/common/dbtest/Entity.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.dbtest;
2 |
3 | import javax.validation.constraints.NotNull;
4 |
5 | /**
6 | * @author Maciej Bilas
7 | * @since 15/12/11 12:46
8 | */
9 | public class Entity {
10 |
11 | @NotNull
12 | private String field;
13 |
14 | Entity() {
15 | }
16 |
17 | Entity(String field) {
18 | this.field = field;
19 | }
20 |
21 | public String getField() {
22 | return field;
23 | }
24 |
25 | public void setField(String field) {
26 | this.field = field;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/softwaremill-backup/src/main/java/com/softwaremill/common/backup/SimpleDBRegion.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.backup;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public enum SimpleDBRegion {
7 | EUROPE_WEST("sdb.eu-west-1.amazonaws.com"),
8 | US_EAST("sdb.amazonaws.com"),
9 | US_WEST("sdb.us-west-1.amazonaws.com"),
10 | ASIA_SOUTHEAST("sdb.ap-southeast-1.amazonaws.com");
11 |
12 | private final String address;
13 |
14 | SimpleDBRegion(String address) {
15 | this.address = address;
16 | }
17 |
18 | public String getAddress() {
19 | return address;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/softwaremill-util/src/main/java/com/softwaremill/common/util/SecsToMills.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util;
2 |
3 | /**
4 | * Constants to avoid code comments like
5 | * private static long TIMEOUT = 10000l; // 10s
6 | *
7 | * @author Pawel Wrzeszcz (pawel [at] softwaremill . com)
8 | */
9 | public class SecsToMills {
10 |
11 | public static final long ONE_SECOND = 1000L;
12 | public static final long TWO_SECONDS = 2 * ONE_SECOND;
13 | public static final long TEN_SECONDS = 10 * ONE_SECOND;
14 |
15 | public static final long ONE_MINUTE = 60 * ONE_SECOND;
16 | public static final long TWO_MINUTES = 2 * ONE_MINUTE;
17 | }
18 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/autofactory/producer/ExampleProductQualifier.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory.producer;
2 |
3 | import javax.inject.Qualifier;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | /**
10 | * @author Adam Warski (adam at warski dot org)
11 | */
12 | @Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER })
13 | @Retention(RetentionPolicy.RUNTIME)
14 | @Qualifier
15 | public @interface ExampleProductQualifier {
16 | }
17 |
--------------------------------------------------------------------------------
/softwaremill-conf/src/main/java/com/softwaremill/common/conf/JBoss7DeployPropertiesProvider.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.conf;
2 |
3 | /**
4 | * JBoss 7 configuration provider
5 | */
6 | public class JBoss7DeployPropertiesProvider extends FolderPropertiesProvider {
7 | public static final String JBOSS_CONFIG_DIR_PROPERTY = "jboss.server.config.dir";
8 |
9 | @Override
10 | public String lookupConfigDirectory() {
11 | return "file:///" + System.getProperty(JBOSS_CONFIG_DIR_PROPERTY);
12 | }
13 |
14 | @Override
15 | public boolean providerAvailable() {
16 | return System.getProperty(JBOSS_CONFIG_DIR_PROPERTY) != null;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/softwaremill-faces/src/main/java/com/softwaremill/common/faces/validator/DelegatingValidator.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.faces.validator;
2 |
3 | import javax.faces.component.UIComponent;
4 | import javax.faces.context.FacesContext;
5 | import javax.faces.validator.FacesValidator;
6 | import javax.faces.validator.Validator;
7 | import javax.faces.validator.ValidatorException;
8 |
9 | /**
10 | * Allow dynamically pass validatorId and delegates validation to validator marked by that id
11 | * Check README.md in softwaremill-faces for an example
12 | */
13 | @FacesValidator("delegatingValidator")
14 | public class DelegatingValidator extends AbstractDelgatingValidator { }
15 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-util/src/main/java/com/softwaremill/common/test/util/Execution.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.test.util;
2 |
3 | /**
4 | * Used in tests to get exception thrown by the closure provided in the execute method.
5 | *
6 | * @author Pawel Wrzeszcz (pawel . wrzeszcz [at] gmail . com)
7 | */
8 | public abstract class Execution {
9 |
10 | private Exception e;
11 |
12 | protected abstract void execute() throws Exception;
13 |
14 | public Exception getException() {
15 | if (e == null) {
16 | try {
17 | execute();
18 | } catch (Exception ex) {
19 | e = ex;
20 | }
21 | }
22 |
23 | return e;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/security/SecurityConditionException.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class SecurityConditionException extends RuntimeException {
7 | public SecurityConditionException() {
8 | }
9 |
10 | public SecurityConditionException(String message) {
11 | super(message);
12 | }
13 |
14 | public SecurityConditionException(String message, Throwable cause) {
15 | super(message, cause);
16 | }
17 |
18 | public SecurityConditionException(Throwable cause) {
19 | super(cause);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/security/SecureBinding.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * A meta-annotations which should be placed on annotations that specify security constraints using @{@link Secure},
10 | * or other secure binding annotations.
11 | * @author Adam Warski (adam at warski dot org)
12 | */
13 | @Target({ ElementType.TYPE, ElementType.METHOD })
14 | @Retention(RetentionPolicy.RUNTIME)
15 | public @interface SecureBinding {
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/softwaremill-util/src/main/java/com/softwaremill/common/util/time/RealTimeClock.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util.time;
2 |
3 | import org.joda.time.DateTime;
4 | import org.joda.time.DateTimeZone;
5 |
6 | /**
7 | * Provides time basing on system clock.
8 | */
9 | public class RealTimeClock implements Clock {
10 |
11 | @Override
12 | public DateTime currentDateTime() {
13 | return DateTime.now();
14 | }
15 |
16 | @Override
17 | public DateTime currentDateTimeUTC() {
18 | return DateTime.now(DateTimeZone.UTC);
19 | }
20 |
21 | @Override
22 | public long currentTimeMillis() {
23 | return System.currentTimeMillis();
24 | }
25 | }
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/autofactory/extension/parameter/FactoryParameterParameterValue.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory.extension.parameter;
2 |
3 | import javax.enterprise.inject.spi.BeanManager;
4 |
5 | /**
6 | * @author Adam Warski (adam at warski dot org)
7 | */
8 | public class FactoryParameterParameterValue implements ParameterValue {
9 | private final int idx;
10 |
11 | public FactoryParameterParameterValue(int idx) {
12 | this.idx = idx;
13 | }
14 |
15 |
16 | @Override
17 | public Object getValue(BeanManager bm, Object[] factoryParameters) {
18 | return factoryParameters[idx];
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-db/src/main/java/com/softwaremill/common/dbtest/util/DbMode.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.dbtest.util;
2 |
3 | /**
4 | * Created by Pawel Stawicki on Mar 31, 2011 9:38:46 PM
5 | */
6 | public enum DbMode {
7 |
8 | DB2("DB2"), Derby("Derby"), HSQLDB("HSQLDB"), MSSQL("MSSQLServer"),
9 | MySQL("MySQL"), Oracle("Oracle"), PostgreSQL("PostgreSQL");
10 |
11 | private DbMode(String compatibilityParamValue) {
12 | this.compatibilityParamValue = compatibilityParamValue;
13 | }
14 |
15 | private String compatibilityParamValue;
16 |
17 | public String getParameterValue() {
18 | return compatibilityParamValue;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/el/ELEvaluatorUtil.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.el;
2 |
3 | import javax.el.ELContext;
4 | import javax.el.ExpressionFactory;
5 |
6 | /**
7 | * @author Adam Warski (adam at warski dot org)
8 | */
9 | public class ELEvaluatorUtil {
10 | @SuppressWarnings({"unchecked"})
11 | public static T evaluate(ELContext elContext, ExpressionFactory expressionFactory, String expression,
12 | Class expectedResultType) {
13 | return (T) expressionFactory
14 | .createValueExpression(elContext, expression, expectedResultType)
15 | .getValue(elContext);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/persistence/QueryCreator.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.persistence;
2 |
3 | import javax.persistence.EntityManager;
4 | import javax.persistence.Query;
5 |
6 | /**
7 | * Creates a query. Can be used to properly execute bulk update queries using
8 | * {@link com.softwaremill.common.cdi.persistence.EntityWriter#executeUpdate(QueryCreator)}.
9 | * @author Adam Warski (adam at warski dot org)
10 | */
11 | public interface QueryCreator {
12 | /**
13 | * Given an entity manager, creates a query to execute.
14 | * @param em Entity manager
15 | * @return Query to execute.
16 | */
17 | Query createQuery(EntityManager em);
18 | }
19 |
--------------------------------------------------------------------------------
/softwaremill-paypal/src/main/java/com/softwaremill/common/paypal/process/processors/InvalidPayPalProcessor.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.paypal.process.processors;
2 |
3 | import com.softwaremill.common.paypal.process.PayPalParameters;
4 | import com.softwaremill.common.paypal.process.status.PayPalStatus;
5 |
6 | public class InvalidPayPalProcessor extends AbstractPayPalProcessor {
7 |
8 | @Override
9 | public boolean accept(PayPalStatus status) {
10 | return status.isInvalid();
11 | }
12 |
13 | @Override
14 | public void process(PayPalStatus status, PayPalParameters parameters) {
15 | setErrorHappened();
16 | appendError("Paypal replied INVALID for a request.\n\n");
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/transaction/TransactionTimeout.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.transaction;
2 |
3 | import javax.enterprise.util.Nonbinding;
4 | import javax.interceptor.InterceptorBinding;
5 | import java.lang.annotation.*;
6 |
7 | /**
8 | * Changes current trancation timeout
9 | * @author Adam Warski (adam at warski dot org)
10 | */
11 | @Inherited
12 | @InterceptorBinding
13 | @Target({ElementType.TYPE, ElementType.METHOD})
14 | @Retention(RetentionPolicy.RUNTIME)
15 | public @interface TransactionTimeout {
16 | /**
17 | * New value of the transaction timeout in seconds
18 | *
19 | * @return Transaction timeout
20 | */
21 | @Nonbinding int timeout();
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-ui-swing/src/main/java/com/softwaremill/test/swing/TeamCityScreenShotOnFailureListener.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.test.swing;
2 |
3 | import org.assertj.swing.testng.listener.AbstractTestListener;
4 | import org.testng.ITestNGListener;
5 | import org.testng.ITestResult;
6 |
7 | class TeamCityScreenShotOnFailureListener extends AbstractTestListener implements ITestNGListener {
8 |
9 | private GuiScreenShotTaker screenshot;
10 |
11 | TeamCityScreenShotOnFailureListener() {
12 | screenshot = new GuiScreenShotTaker();
13 | }
14 |
15 | @Override
16 | public void onTestFailure(ITestResult result) {
17 | screenshot.take(result.getTestClass().getName());
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-util/src/main/java/com/softwaremill/common/test/util/ExtMockito.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.test.util;
2 |
3 | import org.mockito.cglib.proxy.Factory;
4 |
5 | import static com.google.common.base.Preconditions.checkNotNull;
6 |
7 | /**
8 | * Extensions to Mockito mocking framework.
9 | *
10 | * @author Maciej Bilas
11 | * @since 15/12/11 13:05
12 | */
13 | public class ExtMockito {
14 |
15 | /**
16 | * Checks if the given object is a mock.
17 | *
18 | * @param o
19 | * @return
20 | * @throws NullPointerException if {@code o} is {@code null}
21 | */
22 | public static boolean isAMock(Object o) {
23 | return checkNotNull(o) instanceof Factory;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-arquillian/src/main/java/com/softwaremill/common/arquillian/ManifestUtil.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.arquillian;
2 |
3 | import com.google.common.base.Charsets;
4 | import org.jboss.shrinkwrap.api.Archive;
5 | import org.jboss.shrinkwrap.api.ArchivePaths;
6 | import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
7 | import org.jboss.shrinkwrap.api.container.ManifestContainer;
8 |
9 | public class ManifestUtil {
10 | public static & ManifestContainer> T addEmptyBeansXml(T archive) {
11 | return archive.addAsManifestResource(
12 | new ByteArrayAsset("".getBytes(Charsets.UTF_8)),
13 | ArchivePaths.create("META-INF/beans.xml"));
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-util/src/main/java/com/softwaremill/common/test/util/reorder/LastTest.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.test.util.reorder;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.Target;
5 |
6 | import static java.lang.annotation.ElementType.METHOD;
7 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
8 |
9 | /**
10 | * Marker to place test method as a last to run in its class.
11 | *
12 | * Beware that not all methods can be reordered, only those which don't have any methods depended upon
13 | * (for more see javadoc for org.testng.IMethodInterceptor)
14 | *
15 | * @author Tomasz Dziurko
16 | */
17 | @Target(METHOD)
18 | @Retention(RUNTIME)
19 | public @interface LastTest {
20 | }
21 |
--------------------------------------------------------------------------------
/softwaremill-util/src/main/java/com/softwaremill/common/util/io/InputStreamInputSupplier.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util.io;
2 |
3 | import com.google.common.io.InputSupplier;
4 |
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 |
8 | /**
9 | * An input supplier which holds a reference to an input stream.
10 | * @author Adam Warski (adam at warski dot org)
11 | */
12 | public class InputStreamInputSupplier implements InputSupplier {
13 | private final InputStream stream;
14 |
15 | public InputStreamInputSupplier(InputStream stream) {
16 | this.stream = stream;
17 | }
18 |
19 | @Override
20 | public InputStream getInput() throws IOException {
21 | return stream;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/security/AllowWithFlag.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.Target;
5 |
6 | import static java.lang.annotation.ElementType.*;
7 | import static java.lang.annotation.RetentionPolicy.*;
8 |
9 | /**
10 | * Allows access when any of the given security flags are set.
11 | * Has higher priority than restrictions specified with @{@link Secure}, that is when access is granted basing
12 | * on security flags, other restrictions are not checked.
13 | * @author Adam Warski (adam at warski dot org)
14 | */
15 | @Retention(RUNTIME)
16 | @Target({TYPE, METHOD})
17 | public @interface AllowWithFlag {
18 | String[] value();
19 | }
20 |
--------------------------------------------------------------------------------
/softwaremill-paypal/src/test/java/com/softwaremill/common/paypal/process/TestErrorHandler.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.paypal.process;
2 |
3 | import java.util.logging.Logger;
4 |
5 | /**
6 | * @Author: lukasz.zuchowski at gmail dot com
7 | * Date: 05.04.12
8 | * Time: 12:38
9 | */
10 | public class TestErrorHandler extends PayPalErrorHandler {
11 |
12 | private Logger logger = Logger.getLogger(TestErrorHandler.class.getName());
13 |
14 | @Override
15 | public PayPalErrorHandler.ErrorMessage prepareErrorMessage() {
16 | return new ErrorMessage();
17 | }
18 |
19 | @Override
20 | public void processErrorMessage(PayPalErrorHandler.ErrorMessage errorMessage) {
21 | logger.info(errorMessage.toString());
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/softwaremill-sqs/src/main/java/com/softwaremill/common/sqs/exception/SQSRuntimeException.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.sqs.exception;
2 |
3 | /**
4 | * Runtime Exception wrapping SQS exceptions
5 | *
6 | * @author Jaroslaw Kijanowski - jarek@softwaremill.pl
7 | * Date: Aug 17, 2010
8 | */
9 | public class SQSRuntimeException extends RuntimeException{
10 |
11 | public SQSRuntimeException() {
12 | super();
13 | }
14 |
15 | public SQSRuntimeException(String message) {
16 | super(message);
17 | }
18 |
19 | public SQSRuntimeException(String message, Throwable cause) {
20 | super(message, cause);
21 | }
22 |
23 | public SQSRuntimeException(Throwable cause) {
24 | super(cause);
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/interceptor/NullToEmptyStringParams.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.interceptor;
2 |
3 | import javax.interceptor.InterceptorBinding;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.*;
8 | import static java.lang.annotation.RetentionPolicy.*;
9 |
10 | /**
11 | * Method annotated with @NullToEmptyStringParams will never receive null values for String parameters.
12 | * Parameter values will be converted to empty Strings instead.
13 | *
14 | * @author Pawel Wrzeszcz (pawel [at] softwaremill . com)
15 | */
16 | @InterceptorBinding
17 | @Target({METHOD, TYPE})
18 | @Retention(RUNTIME)
19 | public @interface NullToEmptyStringParams {}
20 |
--------------------------------------------------------------------------------
/softwaremill-util/src/main/java/com/softwaremill/common/util/templates/TemplateContentData.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util.templates;
2 |
3 | /**
4 | * Object with String data: subject and content
5 | *
6 | * @author maciek
7 | */
8 | public class TemplateContentData {
9 |
10 | private String subject;
11 | private String content;
12 |
13 | public TemplateContentData() {
14 |
15 | }
16 |
17 | public String getSubject() {
18 | return subject;
19 | }
20 |
21 | public void setSubject(String subject) {
22 | this.subject = subject;
23 | }
24 |
25 | public String getContent() {
26 | return content;
27 | }
28 |
29 | public void setContent(String content) {
30 | this.content = content;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/softwaremill-paypal/src/main/java/com/softwaremill/common/paypal/process/processors/UnknownPayPalProcessor.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.paypal.process.processors;
2 |
3 | import com.softwaremill.common.paypal.process.PayPalParameters;
4 | import com.softwaremill.common.paypal.process.status.PayPalStatus;
5 |
6 | public class UnknownPayPalProcessor extends AbstractPayPalProcessor {
7 |
8 | @Override
9 | public boolean accept(PayPalStatus status) {
10 | return status.isUnknown();
11 | }
12 |
13 | @Override
14 | public void process(PayPalStatus status, PayPalParameters parameters) {
15 | setErrorHappened().appendError("Paypal replied some unknown response: ")
16 | .appendError(status.toString()).appendError(" for a request.\n\n");
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-db/src/main/java/com/softwaremill/common/dbtest/UtxDependencyProvider.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.dbtest;
2 |
3 | import bitronix.tm.TransactionManagerServices;
4 | import com.softwaremill.common.util.dependency.DependencyProvider;
5 |
6 | import javax.transaction.UserTransaction;
7 | import java.lang.annotation.Annotation;
8 |
9 | /**
10 | * Provides wrapping class to inject UserTransaction
11 | */
12 | public class UtxDependencyProvider implements DependencyProvider {
13 |
14 | @Override
15 | public T inject(Class cls, Annotation... qualifiers) {
16 | if (cls.isAssignableFrom(UserTransaction.class)) {
17 | return (T) TransactionManagerServices.getTransactionManager();
18 | }
19 | return null;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-util/src/main/java/com/softwaremill/common/test/util/reorder/TestOrder.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.test.util.reorder;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.Target;
5 |
6 | import static java.lang.annotation.ElementType.METHOD;
7 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
8 |
9 | /**
10 | * Marker to define order in which test methods in class should be run
11 | *
12 | * Beware that not all methods can be reordered, only those which don't have any methods depended upon
13 | * (for more see javadoc for org.testng.IMethodInterceptor)
14 | *
15 | * @author Tomasz Dziurko
16 | */
17 | @Target(METHOD)
18 | @Retention(RUNTIME)
19 | public @interface TestOrder {
20 |
21 | int order() default 0;
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/softwaremill-faces/src/main/java/com/softwaremill/common/faces/messages/FacesMessagesListener.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.faces.messages;
2 |
3 | import com.softwaremill.common.cdi.util.BeanInject;
4 |
5 | import javax.faces.event.AbortProcessingException;
6 | import javax.faces.event.SystemEvent;
7 | import javax.faces.event.SystemEventListener;
8 |
9 | /**
10 | * @author Adam Warski (adam at warski dot org)
11 | */
12 | public class FacesMessagesListener implements SystemEventListener {
13 | @Override
14 | public void processEvent(SystemEvent event) throws AbortProcessingException {
15 | BeanInject.lookup(FacesMessages.class).beforeRenderResponse();
16 | }
17 |
18 | @Override
19 | public boolean isListenerForSource(Object source) {
20 | return true;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/softwaremill-conf/src/main/java/com/softwaremill/common/conf/encoding/ConfigurationValueCoder.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.conf.encoding;
2 |
3 | /**
4 | * Encodes and decodes configuration values.
5 | * @author Adam Warski (adam at warski dot org)
6 | */
7 | public class ConfigurationValueCoder {
8 | private final static String ENCODED_VALUE_PREFIX = "encoded.";
9 |
10 | private TextCoder coder = new TextCoder();
11 |
12 | public String encode(String value) {
13 | return ENCODED_VALUE_PREFIX + coder.encode(value);
14 | }
15 |
16 | public String decode(String value) {
17 | return coder.decode(value.substring(ENCODED_VALUE_PREFIX.length()));
18 | }
19 |
20 | public boolean isEncoded(String value) {
21 | return value.startsWith(ENCODED_VALUE_PREFIX);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-db/src/test/java/com/softwaremill/common/dbtest/TestEntity1Reader.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.dbtest;
2 |
3 | import com.softwaremill.common.cdi.persistence.ReadOnly;
4 |
5 | import javax.enterprise.context.RequestScoped;
6 | import javax.inject.Inject;
7 | import javax.persistence.EntityManager;
8 | import java.util.List;
9 |
10 | /**
11 | * A helper bean for reading test entities.
12 | * @author Adam Warski (adam at warski dot org)
13 | */
14 | @RequestScoped
15 | public class TestEntity1Reader {
16 | @Inject
17 | @ReadOnly
18 | private EntityManager em;
19 |
20 | @SuppressWarnings({"unchecked"})
21 | public List getCurrentData() {
22 | return em.createQuery("select t from TestEntity1 t order by t.id").getResultList();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/softwaremill-debug/src/main/java/com/softwaremill/common/debug/timing/TimingOutputFilter.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.debug.timing;
2 |
3 | import javax.servlet.*;
4 | import java.io.IOException;
5 |
6 | /**
7 | * @author Adam Warski (adam at warski dot org)
8 | */
9 | public class TimingOutputFilter implements Filter {
10 | @Override
11 | public void init(FilterConfig filterConfig) throws ServletException { }
12 |
13 | @Override
14 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
15 | throws IOException, ServletException {
16 | try {
17 | chain.doFilter(request, response);
18 | } finally {
19 | TimingResults.instance.dumpCurrent();
20 | }
21 | }
22 |
23 | @Override
24 | public void destroy() { }
25 | }
26 |
--------------------------------------------------------------------------------
/softwaremill-sqs/src/main/java/com/softwaremill/common/sqs/email/SendEmailTaskExecutor.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.sqs.email;
2 |
3 | import com.softwaremill.common.task.TaskExecutor;
4 |
5 | import javax.mail.MessagingException;
6 |
7 | import static com.softwaremill.common.sqs.SQSConfiguration.*;
8 |
9 | /**
10 | * @author Adam Warski (adam at warski dot org)
11 | */
12 | public class SendEmailTaskExecutor implements TaskExecutor {
13 | @Override
14 | public void execute(SendEmailTask task) {
15 | try {
16 | EmailSender.send(EMAIL_SMTP_HOST, EMAIL_SMTP_PORT, EMAIL_SMTP_USERNAME, EMAIL_SMTP_PASSWORD,
17 | EMAIL_FROM, ENCODING, task.getEmail());
18 | } catch (MessagingException e) {
19 | throw new RuntimeException(e);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-ui-web/src/main/java/com/softwaremill/common/test/web/email/EmailHeader.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.test.web.email;
2 |
3 | /**
4 | * Most common headers available in email
5 | *
6 | * @author maciek
7 | */
8 | public enum EmailHeader {
9 |
10 | MIME_VERSION("MIME-Version"),
11 |
12 | MESSAGE_ID("Message-ID"),
13 |
14 | SUBJECT("Subject"),
15 |
16 | DATE("Date"),
17 |
18 | CONTENT_TRANSFER_ENCODING("Content-Transfer-Encoding"),
19 |
20 | TO("To"),
21 |
22 | CONTENT_TYPE("Content-Type"),
23 |
24 | FROM("From"),
25 |
26 | REPLY_TO("Reply-To");
27 |
28 | private String value;
29 |
30 | EmailHeader(String headerName){
31 | this.value = headerName;
32 | }
33 |
34 | public String getValue() {
35 | return value;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/logger/LoggerProducer.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.logger;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 |
6 | import javax.enterprise.inject.Produces;
7 | import javax.enterprise.inject.spi.Bean;
8 | import javax.enterprise.inject.spi.InjectionPoint;
9 |
10 | /**
11 | * @author Adam Warski (adam at warski dot org)
12 | */
13 | public class LoggerProducer {
14 |
15 | @Produces
16 | public Logger produceLog(InjectionPoint injectionPoint) {
17 | Bean> bean = injectionPoint.getBean();
18 | if (bean == null) {
19 | return LoggerFactory.getLogger(injectionPoint.getMember().getDeclaringClass());
20 | } else {
21 | return LoggerFactory.getLogger(bean.getBeanClass());
22 | }
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/softwaremill-sqs/src/main/java/com/softwaremill/common/sqs/util/AttachmentDescription.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.sqs.util;
2 |
3 | /**
4 | * @author Adam Warski (adam at warski dot org)
5 | */
6 | public class AttachmentDescription {
7 | private final byte[] content;
8 | private final String filename;
9 | private final String contentType;
10 |
11 | public AttachmentDescription(byte[] content, String filename, String contentType) {
12 | this.content = content;
13 | this.filename = filename;
14 | this.contentType = contentType;
15 | }
16 |
17 | public byte[] getContent() {
18 | return content;
19 | }
20 |
21 | public String getFilename() {
22 | return filename;
23 | }
24 |
25 | public String getContentType() {
26 | return contentType;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/softwaremill-util/src/main/java/com/softwaremill/common/util/time/FixtureTimeClock.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util.time;
2 |
3 | import org.joda.time.DateTime;
4 | import org.joda.time.DateTimeZone;
5 |
6 | /**
7 | * Class responsible for providing arbitrary fixed current time value.
8 | */
9 | public class FixtureTimeClock implements Clock {
10 |
11 | private long millis;
12 |
13 | public FixtureTimeClock(long millis) {
14 | this.millis = millis;
15 | }
16 |
17 | @Override
18 | public DateTime currentDateTime() {
19 | return new DateTime(millis);
20 | }
21 |
22 | @Override
23 | public DateTime currentDateTimeUTC() {
24 | return new DateTime(millis, DateTimeZone.UTC);
25 | }
26 |
27 | @Override
28 | public long currentTimeMillis() {
29 | return millis;
30 | }
31 | }
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/el/ELEvaluatorProducer.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.el;
2 |
3 | import javax.enterprise.context.RequestScoped;
4 | import javax.enterprise.inject.Produces;
5 | import javax.enterprise.inject.spi.BeanManager;
6 | import javax.faces.context.FacesContext;
7 | import javax.inject.Inject;
8 |
9 | /**
10 | * @author Adam Warski (adam at warski dot org)
11 | */
12 | public class ELEvaluatorProducer {
13 | @Inject
14 | private BeanManager beanManager;
15 |
16 | @Produces @RequestScoped
17 | public ELEvaluator getEvaluator() {
18 | if (FacesContext.getCurrentInstance() != null) {
19 | return new FacesContextELEvaluator(FacesContext.getCurrentInstance());
20 | } else {
21 | return new TemporaryContextELEvaluator(beanManager);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/softwaremill-paypal/src/main/java/com/softwaremill/common/paypal/process/processors/AbstractPayPalProcessor.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.paypal.process.processors;
2 |
3 | public abstract class AbstractPayPalProcessor implements PayPalProcessor {
4 |
5 | private StringBuilder errorMessage = new StringBuilder();
6 | private boolean error = false;
7 |
8 | @Override
9 | public boolean isError() {
10 | return error;
11 | }
12 |
13 | @Override
14 | public String getErrorMessage() {
15 | return errorMessage.toString();
16 | }
17 |
18 | protected AbstractPayPalProcessor appendError(String message) {
19 | errorMessage.append(message);
20 | return this;
21 | }
22 |
23 | protected AbstractPayPalProcessor setErrorHappened() {
24 | error = true;
25 | return this;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/objectservice/OSP.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * An object service provider.
7 | * @author Adam Warski (adam at warski dot org)
8 | */
9 | public interface OSP> extends Serializable {
10 | /**
11 | * Finds the appropriate object service for the given object, that is, finds a bean implementing the service
12 | * interface (as specified in the type parameter {@link S}), for which the type parameter corresponds to the
13 | * class of the bean passed.
14 | *
15 | * A new instance of an object service is created on each invocation.
16 | *
17 | * @param o The object for which to get the object service.
18 | * @return An object service for the given object.
19 | */
20 | S f(O o);
21 | }
22 |
--------------------------------------------------------------------------------
/softwaremill-sqs/src/main/java/com/softwaremill/common/sqs/util/SQSAnswer.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.sqs.util;
2 |
3 | /**
4 | * Wrapper class for message received from a SQS queue and converted to an object
5 | * and the SQS Message handle for further reference (to delete or modify (timeout) a message)
6 | *
7 | * @author Jaroslaw Kijanowski - jarek@softwaremill.pl
8 | * Date: Aug 16, 2010
9 | */
10 | public class SQSAnswer {
11 |
12 | private final Object message;
13 | private final String receiptHandle;
14 |
15 | public SQSAnswer(Object message, String receiptHandle) {
16 | this.message = message;
17 | this.receiptHandle = receiptHandle;
18 | }
19 |
20 | public Object getMessage() {
21 | return message;
22 | }
23 |
24 | public String getReceiptHandle() {
25 | return receiptHandle;
26 | }
27 |
28 | }
--------------------------------------------------------------------------------
/softwaremill-util/src/main/java/com/softwaremill/common/util/stringsorting/ByteByByteStringComparator.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util.stringsorting;
2 |
3 | import com.google.common.primitives.UnsignedBytes;
4 |
5 | import java.io.Serializable;
6 | import java.nio.charset.Charset;
7 | import java.util.Comparator;
8 |
9 | /**
10 | * @author Adam Warski (adam at warski dot org)
11 | */
12 | public class ByteByByteStringComparator implements Comparator, Serializable {
13 | @Override
14 | public int compare(String o1, String o2) {
15 | if (o1 == null) {
16 | return o2 == null ? 0 : -1;
17 | }
18 |
19 | if (o2 == null) {
20 | return 1;
21 | }
22 |
23 | return UnsignedBytes.lexicographicalComparator().compare(o1.getBytes(Charset.defaultCharset()), o2.getBytes(Charset.defaultCharset()));
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/persistence/EntityManagerUtil.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.persistence;
2 |
3 | import org.hibernate.FlushMode;
4 | import org.hibernate.Session;
5 |
6 | import javax.persistence.EntityManager;
7 |
8 | /**
9 | * @author Adam Warski (adam at warski dot org)
10 | */
11 | public class EntityManagerUtil {
12 | /**
13 | * Changes the given entity manager to be read only. No changes will be flushed automatically. Also all entities
14 | * will be marked as read only by Hibernate.
15 | * @param em The entity manager to make read only.
16 | */
17 | public static void makeEntityManagerReadOnly(EntityManager em) {
18 | Session readOnlySession = (Session) em.getDelegate();
19 | readOnlySession.setDefaultReadOnly(true);
20 | readOnlySession.setFlushMode(FlushMode.MANUAL);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/sysprops/SystemProperty.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.sysprops;
2 |
3 | import javax.enterprise.util.Nonbinding;
4 | import javax.inject.Qualifier;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | import static java.lang.annotation.ElementType.*;
10 |
11 | /**
12 | * @author Maciej Bilas
13 | * @since 14/9/12 16:33
14 | */
15 | @Qualifier
16 | @Retention(RetentionPolicy.RUNTIME)
17 | @Target({METHOD, FIELD, PARAMETER, TYPE})
18 | public @interface SystemProperty {
19 | public static final String NOT_SET = "[no default set]";
20 |
21 | @Nonbinding public String value() default NOT_SET;
22 |
23 | @Nonbinding public String key() default NOT_SET;
24 |
25 | @Nonbinding public String defaultValue() default NOT_SET;
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/softwaremill-conf/src/main/java/com/softwaremill/common/conf/encoding/MasterPasswordStore.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.conf.encoding;
2 |
3 | import java.io.IOException;
4 |
5 | /**
6 | * @author Adam Warski (adam at warski dot org)
7 | */
8 | public class MasterPasswordStore {
9 | private static String masterPassword;
10 |
11 | public static String getMasterPassword() {
12 | if (masterPassword == null) {
13 | throw new IllegalStateException("Master password not set!");
14 | }
15 |
16 | return masterPassword;
17 | }
18 |
19 | public static void setMasterPassword(String masterPassword) {
20 | MasterPasswordStore.masterPassword = masterPassword;
21 | }
22 |
23 | public static void readFromConsole() throws IOException {
24 | masterPassword = new String(System.console().readPassword("Master password: "));
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/validation/NoSpecialCharsValidator.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.validation;
2 |
3 | import javax.validation.ConstraintValidator;
4 | import javax.validation.ConstraintValidatorContext;
5 | import java.util.regex.Pattern;
6 |
7 | /**
8 | * Created by amorfis on Dec 3, 2010 1:34:27 PM
9 | */
10 | public class NoSpecialCharsValidator implements ConstraintValidator {
11 |
12 | Pattern regex;
13 |
14 | public void initialize(NoSpecialChars constraint) {
15 | String charsAllowed = constraint.charsAllowed();
16 | regex = Pattern.compile("^[A-Za-z0-9" + charsAllowed + "]*$");
17 | }
18 |
19 | public boolean isValid(String value, ConstraintValidatorContext context) {
20 | if (value == null) return true;
21 |
22 | return regex.matcher(value).matches();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/softwaremill-conf/src/main/java/com/softwaremill/common/conf/ClasspathPropertiesProvider.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.conf;
2 |
3 | import com.google.common.collect.ImmutableMap;
4 | import com.google.common.io.Resources;
5 |
6 | import java.net.URL;
7 |
8 | /**
9 | * @author Adam Warski (adam at warski dot org)
10 | */
11 | public class ClasspathPropertiesProvider implements PropertiesProvider {
12 | @Override
13 | public ImmutableMap lookupProperties(String name) {
14 | try {
15 | URL resource = Resources.getResource(name + ".conf");
16 | return Configuration.loadFromURL(resource);
17 | } catch (IllegalArgumentException e) {
18 | // Resource not found.
19 | return null;
20 | }
21 | }
22 |
23 | @Override
24 | public boolean providerAvailable() {
25 | return true;
26 | }
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/softwaremill-sqs/src/main/java/com/softwaremill/common/sqs/ReceivedMessage.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.sqs;
2 |
3 | /**
4 | * @author Maciej Bilas
5 | * @since 11/10/12 12:43
6 | */
7 | public class ReceivedMessage {
8 |
9 | private final Object message;
10 | private final ReceiptHandle receiptHandle;
11 | private final MessageId messageId;
12 |
13 | public ReceivedMessage(Object message, ReceiptHandle receiptHandle,
14 | MessageId messageId) {
15 | this.message = message;
16 | this.receiptHandle = receiptHandle;
17 | this.messageId = messageId;
18 | }
19 |
20 | public Object getMessage() {
21 | return message;
22 | }
23 |
24 | public ReceiptHandle getReceiptHandle() {
25 | return receiptHandle;
26 | }
27 |
28 | public MessageId getMessageId() {
29 | return messageId;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-db/src/test/java/com/softwaremill/common/dbtest/TestEntity1Manager.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.dbtest;
2 |
3 | import com.softwaremill.common.cdi.persistence.EntityWriter;
4 | import com.softwaremill.common.cdi.transaction.Transactional;
5 |
6 | import javax.inject.Inject;
7 | import java.util.List;
8 |
9 | /**
10 | * A manager for the test entity: enables reads (via an injected bean) and writes via entity writer.
11 | * @author Adam Warski (adam at warski dot org)
12 | */
13 | @Transactional
14 | public class TestEntity1Manager {
15 | @Inject
16 | private TestEntity1Reader reader;
17 |
18 | @Inject
19 | private EntityWriter writer;
20 |
21 | public List getCurrentData() {
22 | return reader.getCurrentData();
23 | }
24 |
25 | public void addEntity(TestEntity1 te) {
26 | writer.write(te);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-ui-swing/src/test/java/com/softwaremill/test/swing/AppTest.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.test.swing;
2 |
3 | import junit.framework.Test;
4 | import junit.framework.TestCase;
5 | import junit.framework.TestSuite;
6 |
7 | /**
8 | * Unit test for simple App.
9 | */
10 | public class AppTest
11 | extends TestCase
12 | {
13 | /**
14 | * Create the test case
15 | *
16 | * @param testName name of the test case
17 | */
18 | public AppTest( String testName )
19 | {
20 | super( testName );
21 | }
22 |
23 | /**
24 | * @return the suite of tests being tested
25 | */
26 | public static Test suite()
27 | {
28 | return new TestSuite( AppTest.class );
29 | }
30 |
31 | /**
32 | * Rigourous Test :-)
33 | */
34 | public void testApp()
35 | {
36 | assertTrue( true );
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/security/Secure.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.Target;
5 |
6 | import static java.lang.annotation.ElementType.*;
7 | import static java.lang.annotation.RetentionPolicy.*;
8 |
9 | /**
10 | * Checks a condition before executing a method (pre-condition).
11 | * TODO: add an internationalized message
12 | * @author Adam Warski (adam at warski dot org)
13 | */
14 | @Retention(RUNTIME)
15 | @Target({TYPE, METHOD})
16 | public @interface Secure {
17 | /**
18 | * @return The EL expression that should be evaluated. If it evaluates to {@code true}, access will be granted.
19 | * The EL expression may reference any objects that are in any context, as well as any parameters named with
20 | * @{@link SecureVar}.
21 | */
22 | String value();
23 | }
24 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/autofactory/mixed/PriceCalculatorMixedConstructorImpl.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory.mixed;
2 |
3 | import com.softwaremill.common.cdi.autofactory.*;
4 |
5 | import javax.inject.Inject;
6 |
7 | /**
8 | * @author Adam Warski (adam at warski dot org)
9 | */
10 | @CreatedWith(PriceCalculator.Factory.class)
11 | public class PriceCalculatorMixedConstructorImpl implements PriceCalculator {
12 | private final Product product;
13 | private final Discounts discounts;
14 |
15 | @Inject
16 | public PriceCalculatorMixedConstructorImpl(@FactoryParameter Product product, Discounts discounts) {
17 | this.product = product;
18 | this.discounts = discounts;
19 | }
20 |
21 | @Override
22 | public int getFinalPrice() {
23 | return product.getBasePrice() - discounts.getNormalDiscount();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/persistence/MockEntityManagerProducers.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.persistence;
2 |
3 | import javax.enterprise.context.RequestScoped;
4 | import javax.enterprise.inject.Produces;
5 | import java.io.Serializable;
6 |
7 | /**
8 | * The produced entity managers simple delegate to an underlying entity manager, which must be explicitly
9 | * set before using.
10 | * @author Adam Warski (adam at warski dot org)
11 | */
12 | public class MockEntityManagerProducers implements Serializable {
13 | @Produces @RequestScoped @ReadOnly
14 | public EntityManagerDelegator getReadOnlyEntityManager() {
15 | return new EntityManagerDelegator(null);
16 | }
17 |
18 | @Produces @RequestScoped @Writeable
19 | public EntityManagerDelegator getWriteableEntityManager() {
20 | return new EntityManagerDelegator(null);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/conf/ConfValueProducer.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.conf;
2 |
3 | import com.softwaremill.common.conf.Configuration;
4 |
5 | import javax.enterprise.inject.Produces;
6 | import javax.enterprise.inject.spi.InjectionPoint;
7 | import java.util.Map;
8 |
9 | public class ConfValueProducer {
10 | @Produces
11 | @ConfValue(confName = "", confKey = "")
12 | public String getConfigurationValue(InjectionPoint ip) {
13 | ConfValue confValue = ip.getAnnotated().getAnnotation(ConfValue.class);
14 | return Configuration.get(confValue.confName()).get(confValue.confKey());
15 | }
16 |
17 | public static String from(InjectionPoint ip, Map configuration) {
18 | ConfValue confValue = ip.getAnnotated().getAnnotation(ConfValue.class);
19 | return configuration.get(confValue.confKey());
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/security/SecureVar.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * @author Adam Warski (adam at warski dot org)
10 | */
11 | @Target({ ElementType.PARAMETER })
12 | @Retention(RetentionPolicy.RUNTIME)
13 | public @interface SecureVar {
14 | /**
15 | * @return Name of the variable, which will be available when checking security constraints.
16 | */
17 | String value();
18 |
19 | /**
20 | * @return An optional EL expression which will be evaluated to get the value of the variable. The name
21 | * of the paramter during the evaluation is p, so the expression can be e.g.: #{p.attribute}.
22 | */
23 | String exp() default "";
24 | }
25 |
--------------------------------------------------------------------------------
/softwaremill-paypal/src/test/java/com/softwaremill/common/paypal/process/processors/MockVerifiedPayPalProcessor.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.paypal.process.processors;
2 |
3 | import com.softwaremill.common.paypal.process.PayPalParameters;
4 | import com.softwaremill.common.paypal.process.status.PayPalStatus;
5 | import com.softwaremill.common.paypal.service.PayPalVerificationServiceTest;
6 |
7 | import java.util.logging.Logger;
8 |
9 | /**
10 | * @Author: lukasz.zuchowski at gmail dot com
11 | * Date: 05.04.12
12 | * Time: 15:36
13 | */
14 | public class MockVerifiedPayPalProcessor extends VerifiedPayPalProcessor {
15 |
16 | private Logger logger = Logger.getLogger(MockVerifiedPayPalProcessor.class.getName());
17 |
18 | @Override
19 | public void process(PayPalStatus status, PayPalParameters parameters) {
20 | logger.info("process with:" + status + "\n and PayPalParameters");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/resources/hibernate.test.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 | create-drop
9 |
10 | false
11 | true
12 |
13 | org.hibernate.dialect.H2Dialect
14 | jdbc:h2:mem:cdiext
15 | org.h2.Driver
16 | sa
17 |
18 |
19 |
--------------------------------------------------------------------------------
/softwaremill-paypal/src/main/java/com/softwaremill/common/paypal/process/status/PayPalStatus.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.paypal.process.status;
2 |
3 | public class PayPalStatus {
4 |
5 | private String status;
6 |
7 | PayPalStatus(String status) {
8 | this.status = status;
9 | }
10 |
11 | public boolean isVerified() {
12 | return "VERIFIED".equals(status);
13 | }
14 |
15 | public boolean isValidCurrency(String paymentCurrency) {
16 | return "AUD".equals(paymentCurrency);
17 | }
18 |
19 | public boolean isInvalid() {
20 | return "INVALID".equals(status);
21 | }
22 |
23 | public boolean isUnknown() {
24 | return !isVerified() && !isInvalid();
25 | }
26 |
27 | @Override
28 | public String toString() {
29 | return "PayPalStatus{" +
30 | "status='" + status + '\'' +
31 | '}';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/objectservice/extension/PureWildcardType.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice.extension;
2 |
3 | import java.lang.reflect.Type;
4 | import java.lang.reflect.WildcardType;
5 |
6 | /**
7 | * A {@code ?} wildcard.
8 | * @author Adam Warski (adam at warski dot org)
9 | */
10 | public class PureWildcardType implements WildcardType {
11 | private static final Type[] EMPTY_TYPE_ARRAY = new Type[0];
12 |
13 | public static final PureWildcardType INSTANCE = new PureWildcardType();
14 |
15 | private PureWildcardType() {
16 | }
17 |
18 | @Override
19 | public Type[] getUpperBounds() {
20 | return EMPTY_TYPE_ARRAY;
21 | }
22 |
23 | @Override
24 | public Type[] getLowerBounds() {
25 | return EMPTY_TYPE_ARRAY;
26 | }
27 |
28 | @Override
29 | public String toString() {
30 | return "?";
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/autofactory/logger/InjectDataAndLoggerField.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory.logger;
2 |
3 | import org.slf4j.Logger;
4 | import com.softwaremill.common.cdi.autofactory.CreatedWith;
5 |
6 | import javax.inject.Inject;
7 |
8 | /**
9 | * @author Adam Warski (adam at warski dot org)
10 | */
11 | @CreatedWith(InjectDataAndLoggerField.Factory.class)
12 | public class InjectDataAndLoggerField {
13 | private final String data;
14 |
15 | @Inject
16 | private Logger logger;
17 |
18 | public InjectDataAndLoggerField(String data) {
19 | this.data = data;
20 | }
21 |
22 | public String getData() {
23 | return data;
24 | }
25 |
26 | public Logger getLogger() {
27 | return logger;
28 | }
29 |
30 | public static interface Factory {
31 | InjectDataAndLoggerField create(String data);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/security/InterceptSecure.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.security;
2 |
3 | import javax.enterprise.util.Nonbinding;
4 | import javax.interceptor.InterceptorBinding;
5 | import java.lang.annotation.ElementType;
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.RetentionPolicy;
8 | import java.lang.annotation.Target;
9 |
10 | /**
11 | * The annotation the is generated by the {@link com.softwaremill.common.cdi.security.SecurityExtension}, which contains
12 | * all security constraints to be checked.
13 | * @author Adam Warski (adam at warski dot org)
14 | */
15 | @InterceptorBinding
16 | @Target({ ElementType.TYPE, ElementType.METHOD })
17 | @Retention(RetentionPolicy.RUNTIME)
18 | public @interface InterceptSecure {
19 | @Nonbinding
20 | Secure[] value();
21 |
22 | @Nonbinding
23 | AllowWithFlag[] flags() default {};
24 | }
25 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/autofactory/producer/ExamplePriceCalculatorProducer.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory.producer;
2 |
3 | import com.softwaremill.common.cdi.autofactory.PriceCalculator;
4 | import com.softwaremill.common.cdi.autofactory.Product;
5 |
6 | import javax.enterprise.inject.Produces;
7 | import javax.inject.Inject;
8 |
9 | /**
10 | * @author Adam Warski (adam at warski dot org)
11 | */
12 | public class ExamplePriceCalculatorProducer {
13 | private final PriceCalculator.Factory priceCalculatorFactory;
14 |
15 | @Inject
16 | public ExamplePriceCalculatorProducer(PriceCalculator.Factory priceCalculatorFactory) {
17 | this.priceCalculatorFactory = priceCalculatorFactory;
18 | }
19 |
20 | @Produces @ExampleProductQualifier
21 | public PriceCalculator create() {
22 | return priceCalculatorFactory.create(new Product(0));
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/softwaremill-debug/src/main/java/com/softwaremill/common/debug/timing/TimingInterceptor.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.debug.timing;
2 |
3 | import javax.interceptor.AroundInvoke;
4 | import javax.interceptor.Interceptor;
5 | import javax.interceptor.InvocationContext;
6 | import java.io.Serializable;
7 |
8 | /**
9 | * @link http://seamframework.org/Community/SeamPerformanceProblemRewardingWorkaround
10 | * @author Tobias Hill
11 | * @author Adam Warski
12 | */
13 | @Interceptor
14 | @Timed
15 | public class TimingInterceptor implements Serializable {
16 | @AroundInvoke
17 | public Object timeCall(InvocationContext invocation) throws Exception {
18 | long t0 = System.nanoTime();
19 | try {
20 | return invocation.proceed();
21 | } finally {
22 | long dt = System.nanoTime() - t0;
23 | TimingResults.instance.addInvocation(invocation, dt);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/objectservice/extension/OSPImpl.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice.extension;
2 |
3 | import com.softwaremill.common.cdi.objectservice.OS;
4 | import com.softwaremill.common.cdi.objectservice.OSP;
5 |
6 | /**
7 | * @author Adam Warski (adam at warski dot org)
8 | */
9 | public class OSPImpl implements OSP {
10 | private final ObjectServiceExtension extension;
11 | private final Class> serviceClass;
12 |
13 | public OSPImpl(ObjectServiceExtension extension, Class> serviceClass) {
14 | this.extension = extension;
15 | this.serviceClass = serviceClass;
16 | }
17 |
18 | @Override
19 | public OS f(Object obj) {
20 | OS objectService = (OS) extension.serviceForObject(obj.getClass(), serviceClass);
21 | //noinspection unchecked
22 | objectService.setServiced(obj);
23 | return objectService;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/softwaremill-sqs/src/main/java/com/softwaremill/common/sqs/email/SendEmailTask.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.sqs.email;
2 |
3 | import com.softwaremill.common.sqs.util.EmailDescription;
4 | import com.softwaremill.common.task.OneTimeTask;
5 | import com.softwaremill.common.task.TaskExecutor;
6 |
7 | /**
8 | * @author Adam Warski (adam at warski dot org)
9 | */
10 | public class SendEmailTask implements OneTimeTask {
11 | private final EmailDescription email;
12 |
13 | public SendEmailTask(EmailDescription email) {
14 | this.email = email;
15 | }
16 |
17 | public EmailDescription getEmail() {
18 | return email;
19 | }
20 |
21 | @Override
22 | public Integer getTaskTimeout() {
23 | return null;
24 | }
25 |
26 | @Override
27 | public Class extends TaskExecutor> getExecutorBeanClass() {
28 | return SendEmailTaskExecutor.class;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/softwaremill-conf/src/main/java/com/softwaremill/common/conf/encoding/server/MasterPasswordSetterClient.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.conf.encoding.server;
2 |
3 | import com.google.common.base.Charsets;
4 |
5 | import java.io.IOException;
6 | import java.io.OutputStreamWriter;
7 | import java.io.PrintWriter;
8 | import java.net.Socket;
9 |
10 | /**
11 | * @author Adam Warski (adam at warski dot org)
12 | */
13 | public class MasterPasswordSetterClient {
14 | public static void main(String[] args) throws IOException {
15 | Socket socket = new Socket("localhost", MasterPasswordSetterServer.PORT);
16 |
17 | System.out.println("Please enter the master password:");
18 | String password = System.console().readLine();
19 | new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), Charsets.UTF_8), true).write(password);
20 |
21 | System.out.println("Password sent");
22 |
23 | socket.close();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/softwaremill-faces/src/main/resources/META-INF/smlComponents.taglib.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | http://com.softwaremill.common.faces/components
7 |
8 | multiValidator
9 |
10 | MultiValidator
11 |
12 |
13 |
14 | validator
15 | javax.faces.validator.Validator
16 |
17 |
18 |
19 |
20 | fileUpload
21 |
22 | FileUpload
23 |
24 |
25 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-ui-web/src/main/java/com/softwaremill/common/test/web/jboss/server/JBossASProvider.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.test.web.jboss.server;
2 |
3 | import com.softwaremill.common.test.web.selenium.ServerProperties;
4 |
5 | /**
6 | * @author Pawel Wrzeszcz (pawel [at] softwaremill . com)
7 | */
8 | public class JBossASProvider {
9 |
10 | private final ServerProperties serverProperties;
11 |
12 | public JBossASProvider(ServerProperties serverProperties) {
13 | this.serverProperties = serverProperties;
14 | }
15 |
16 | public JBossAS createJBossASInstance() {
17 | int version = serverProperties.getAsVersion();
18 | switch (version) {
19 | case 5: return new JBossAS5or6(serverProperties);
20 | case 6: return new JBossAS5or6(serverProperties);
21 | case 7: return new JBossAS7(serverProperties);
22 | default: throw new IllegalArgumentException("Not supported JBossAS version: " + version);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/persistence/EntityWithLazySubentity.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.persistence;
2 |
3 | import com.softwaremill.common.util.persistance.Identifiable;
4 |
5 | import javax.persistence.*;
6 |
7 | /**
8 | * @author Pawel Stawicki
9 | * @since 8/13/12 5:30 PM
10 | */
11 | @Entity
12 | public class EntityWithLazySubentity implements Identifiable {
13 |
14 | @Id
15 | @GeneratedValue
16 | private Long id;
17 |
18 | @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
19 | private SimpleEntity subentity;
20 |
21 | public Long getId() {
22 | return id;
23 | }
24 |
25 | public void setId(Long id) {
26 | this.id = id;
27 | }
28 |
29 | public SimpleEntity getSubentity() {
30 | return subentity;
31 | }
32 |
33 | public void setSubentity(SimpleEntity subentity) {
34 | this.subentity = subentity;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/softwaremill-backup/scripts/backup_sdb_and_upload.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Configuration
4 | ###############
5 |
6 | if [ -n $1 ]; then
7 | source $1
8 | else
9 | source backup_conf.sh
10 | fi
11 |
12 |
13 | #########
14 |
15 | CURRENT_YEAR_MONTH=`date +"%Y_%m"`
16 | CURRENT_DATE=`date +"%d_%m_%Y"`
17 | CURRENT_DATE_WITH_HOUR=`date +"%d_%m_%Y__%H_%M"`
18 | TAR_FILE_NAME=simpledb_backup_${CURRENT_DATE_WITH_HOUR}.tar.gz
19 |
20 | # Creating backup files
21 | java -jar $SDB_BACKUP_PATH $SIMPLEDB_ACCESS_KEY_ID $SIMPLEDB_SECRET_ACCESS_KEY $SIMPLEDB_REGION "$SIMPLEDB_DOMAINS"
22 |
23 | # Packing
24 | tar -czf $TAR_FILE_NAME simpledb_backup*${CURRENT_DATE}*.txt
25 |
26 | # Removing backup files
27 | rm simpledb_backup*${CURRENT_DATE}*.txt
28 |
29 | # Uploading to S3
30 | java -cp $SDB_BACKUP_PATH com.softwaremill.common.backup.S3Upload $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY $S3_BUCKET $TAR_FILE_NAME $S3_PREFIX$CURRENT_YEAR_MONTH
31 |
32 | # Cleaning up
33 | rm $TAR_FILE_NAME
34 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-ui-swing/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | softwaremill-test
6 | com.softwaremill.common
7 | 81-SNAPSHOT
8 |
9 |
10 | softwaremill-test-ui-swing
11 | Softwaremill Swing UI Test
12 |
13 |
14 | UTF-8
15 |
16 |
17 |
18 |
19 | org.assertj
20 | assertj-swing-testng
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/main/java/com/softwaremill/common/cdi/autofactory/CreatedWith.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.Target;
5 |
6 | import static java.lang.annotation.ElementType.*;
7 | import static java.lang.annotation.RetentionPolicy.*;
8 |
9 | /**
10 | * Creates an implementation of the specified factory class, which will return instances of the annotated class
11 | * when methods in the created implementation are invoked.
12 | *
13 | * The factory class should contain exactly one method, where the return type is a supertype of the annotated
14 | * class ((e.g. an interface implemented by the annotated class).
15 | *
16 | * The parameters of the factory method should match the arguments of the constructor.
17 | *
18 | * @author Adam Warski (adam at warski dot org)
19 | */
20 | @Target({ TYPE })
21 | @Retention(RUNTIME)
22 | public @interface CreatedWith {
23 | Class> value();
24 | }
25 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-ui-web/src/main/java/com/softwaremill/common/test/web/jboss/DeployementProperties.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.test.web.jboss;
2 |
3 | /**
4 | *
5 | * @author maciek
6 | */
7 | public class DeployementProperties {
8 |
9 | private String appVersion;
10 |
11 | private String earPath;
12 |
13 | private String rorPath;
14 |
15 | /**
16 | * @param appVersion
17 | * @param earPath
18 | * @param rorPath
19 | */
20 | public DeployementProperties(String appVersion, String earPath, String rorPath) {
21 | this.appVersion = appVersion;
22 | this.earPath = earPath;
23 | this.rorPath = rorPath;
24 | }
25 |
26 | public String getAppVersion() {
27 | return appVersion;
28 | }
29 |
30 | public String getEarPath() {
31 | return earPath;
32 | }
33 |
34 | public String getRorPath() {
35 | return rorPath;
36 | }
37 |
38 |
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/softwaremill-test/softwaremill-test-db/src/main/resources/hibernate.test.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 | create-drop
10 |
11 | false
12 | true
13 |
14 | org.hibernate.dialect.H2Dialect
15 | org.h2.Driver
16 | sa
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/Service2C.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice;
2 |
3 | import javax.enterprise.context.RequestScoped;
4 | import java.util.concurrent.atomic.AtomicInteger;
5 |
6 | /**
7 | * A service for which implementations are scoped beans, with instance counters.
8 | * @author Adam Warski (adam at warski dot org)
9 | */
10 | @RequestScoped
11 | public class Service2C implements Service2 {
12 | private C serviced;
13 |
14 | public Service2C() {
15 | instanceCounter.incrementAndGet();
16 | }
17 |
18 | @Override
19 | public void setServiced(C serviced) {
20 | this.serviced = serviced;
21 | }
22 |
23 | @Override
24 | public Object get() {
25 | return serviced.getValue();
26 | }
27 |
28 | private static AtomicInteger instanceCounter = new AtomicInteger();
29 |
30 | public static int instanceCount() {
31 | return instanceCounter.get();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/auto/AutoString.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice.auto;
2 |
3 | import javax.enterprise.context.ApplicationScoped;
4 | import javax.inject.Inject;
5 | import java.io.Serializable;
6 |
7 | @OSImpl
8 | @ApplicationScoped
9 | public class AutoString implements IAuto{
10 |
11 | ExecutionMock execMock;
12 |
13 | Integer invCounter = 0;
14 |
15 | @Inject
16 | public AutoString(ExecutionMock execMock) {
17 | this.execMock = execMock;
18 | }
19 |
20 | public AutoString() {
21 | }
22 |
23 |
24 | @Override
25 | public void doSomething(String bim, String object, Integer bom) {
26 | execMock.stringExecs += 1;
27 |
28 | invCounter += 1;
29 | }
30 |
31 | public Integer getInvCounter() {
32 | return invCounter;
33 | }
34 |
35 | public void setInvCounter(Integer invCounter) {
36 | this.invCounter = invCounter;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/objectservice/Service2B.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.objectservice;
2 |
3 | import javax.enterprise.context.ApplicationScoped;
4 | import java.util.concurrent.atomic.AtomicInteger;
5 |
6 | /**
7 | * A service for which implementations are scoped beans, with instance counters.
8 | * @author Adam Warski (adam at warski dot org)
9 | */
10 | @ApplicationScoped
11 | public class Service2B implements Service2 {
12 | private B serviced;
13 |
14 | public Service2B() {
15 | instanceCounter.incrementAndGet();
16 | }
17 |
18 | @Override
19 | public void setServiced(B serviced) {
20 | this.serviced = serviced;
21 | }
22 |
23 | @Override
24 | public Object get() {
25 | return serviced.getValue();
26 | }
27 |
28 | private static AtomicInteger instanceCounter = new AtomicInteger();
29 |
30 | public static int instanceCount() {
31 | return instanceCounter.get();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/softwaremill-paypal/src/test/java/com/softwaremill/common/paypal/process/status/MockStatusVerifier.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.paypal.process.status;
2 |
3 | import com.softwaremill.common.paypal.process.RequestParameters;
4 |
5 | import java.util.logging.Logger;
6 |
7 | /**
8 | * @Author: lukasz.zuchowski at gmail dot com
9 | * Date: 05.04.12
10 | * Time: 15:13
11 | */
12 | public class MockStatusVerifier implements PayPalStatusVerifier {
13 |
14 | private Logger logger = Logger.getLogger(MockStatusVerifier.class.getName());
15 |
16 | @Override
17 | public PayPalStatus verify(String url, RequestParameters requestParameters) {
18 | logger.info("with PayPal url:" + url);
19 | logger.info("verifying request parameter:" + requestParameters);
20 | //this is not how payPal works. Its just mock implementation.
21 | String status = requestParameters.getParameter(RequestParameters.Parameter.payment_status);
22 | return new PayPalStatus(status);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/softwaremill-cdi/src/test/java/com/softwaremill/common/cdi/autofactory/field/PriceCalculatorFieldInjectionImpl.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.cdi.autofactory.field;
2 |
3 | import com.softwaremill.common.cdi.autofactory.CreatedWith;
4 | import com.softwaremill.common.cdi.autofactory.Discounts;
5 | import com.softwaremill.common.cdi.autofactory.PriceCalculator;
6 | import com.softwaremill.common.cdi.autofactory.Product;
7 |
8 | import javax.inject.Inject;
9 |
10 | /**
11 | * @author Adam Warski (adam at warski dot org)
12 | */
13 | @CreatedWith(PriceCalculator.Factory.class)
14 | public class PriceCalculatorFieldInjectionImpl implements PriceCalculator {
15 | @Inject
16 | private Discounts discounts;
17 |
18 | private final Product product;
19 |
20 | public PriceCalculatorFieldInjectionImpl(Product product) {
21 | this.product = product;
22 | }
23 |
24 | @Override
25 | public int getFinalPrice() {
26 | return product.getBasePrice() - discounts.getNormalDiscount();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/softwaremill-faces/src/main/java/com/softwaremill/common/faces/navigation/CurrentPage.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.faces.navigation;
2 |
3 | import javax.faces.context.FacesContext;
4 | import java.util.Collections;
5 | import java.util.Map;
6 |
7 | /**
8 | * @author Adam Warski (adam at warski dot org)
9 | */
10 | public class CurrentPage extends AbstractPage {
11 |
12 | public CurrentPage() {
13 | super(Collections.emptyMap(), false);
14 | }
15 |
16 | public CurrentPage(Map params, boolean requiresLogin) {
17 | super(params, requiresLogin);
18 | }
19 |
20 | @Override
21 | protected String computeViewId() {
22 | return FacesContext.getCurrentInstance().getViewRoot().getViewId();
23 | }
24 |
25 | public Page copy(Map params, boolean requiresLogin) {
26 | return new CurrentPage(params, requiresLogin);
27 | }
28 |
29 | @Override
30 | public String getSecurityEL() {
31 | return null;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/softwaremill-util/src/main/java/com/softwaremill/common/util/dependency/GlobalDependencyProvider.java:
--------------------------------------------------------------------------------
1 | package com.softwaremill.common.util.dependency;
2 |
3 | import java.lang.annotation.Annotation;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | /**
8 | * @author Adam Warski (adam at warski dot org)
9 | */
10 | public class GlobalDependencyProvider extends AbstractDependencyProvider {
11 | private final List